[{"content":"\nIntroduction Many of us grew up watching the Soviet animated series Kolobki Investigate. The investigation begins with four mysterious holes in a rooftop. The chief detective measures the distance between them with a tape measure and unexpectedly concludes:\n— These holes are elephant footprints. His colleague laughs: — Since when do elephants fly? — Then they do. Imagine that I publish a detailed description of a flying elephant. I carefully document its body size, anatomy, diet, behavior, and geographic distribution, include several well-executed scientific illustrations, and the paper is accepted by a peer-reviewed journal.\nFrom that moment on, a publication exists that others can cite.\nA scientific paper does more than introduce a new claim. It creates a new object of citation. From that point forward, subsequent authors must acknowledge its existence in the literature, regardless of how convincing the original evidence was. Any future author could truthfully write: \u0026ldquo;A description of a flying elephant has been published.\u0026rdquo;\nThe publication itself does not prove that flying elephants exist. However, it introduces a published report of a flying elephant into the scientific literature. That report may be cited, discussed, compared with new observations, and eventually either supported or refuted—even if the original evidence was weak.\nThis is precisely why extraordinary claims require an exceptionally strong evidential foundation.\nYears later I read Vitaly Tanasiychuk\u0026rsquo;s book Incredible Zoology. One chapter tells the story of the German zoologist Gerolf Steiner, who described an entirely fictional order of animals so convincingly that many readers initially accepted it as genuine science. There were Latin names, illustrations, morphology, behavior, taxonomy—everything looked like a real scientific publication.\nToday these stories make us smile. Yet their value was never the joke itself. They demonstrated how easily scientific form can create an illusion of credibility. They remind us of a simple principle: a story is not evidence, even if it later turns out to be correct.\nScientific mistakes rarely happen because researchers deliberately intend to deceive.\nMuch more often, the problem begins when a conclusion starts living independently of the observations on which it was originally based.\nA photograph does not make a hypothesis true. A video does not replace an experiment. However, without them, an observation gradually becomes nothing more than a retold story. Primary documentation allows the next researcher not merely to trust the author, but to evaluate the original observation independently.\nDo not preserve conclusions alone. Preserve the data from which they were drawn.\nWithout primary data, every discovery eventually turns into a retelling.\nThis is how an insufficiently documented claim can gradually become a widely cited fact.\nIf an observation cannot be preserved completely, it should be documented as thoroughly as modern methods allow.\nSeeing Once Is Better Than Hearing a Hundred Times An observation exists only once—the moment a researcher makes it. Everything afterwards depends on how completely that observation has been preserved.\nThe value of photographs, videos, microscope slides, preserved specimens, or living cultures is not limited to illustration. They allow future researchers to examine the original observation rather than relying solely on someone else\u0026rsquo;s description.\nDigital documentation is valuable not only scientifically but educationally as well. It allows biological processes to be shown directly instead of merely described or schematically illustrated.\nWhy should we preserve video? A photograph captures a moment. A video captures a process. Ваш браузер не поддерживает видео. Development of Sumatra barb eggs. In many cases, the process itself contains information that cannot be extracted from a single image. Time-lapse recordings of embryonic development provide an excellent example.\nTime-lapse imaging allows us to observe not only the sequence of changes but also their timing, speed, and the unique characteristics of each developmental stage.\nSuch recordings make it possible to refine existing descriptions and reveal details that are easily overlooked during occasional observations.\nExamples of documented observations:\nMicrophotographs\rGallery\rImages, videos, and visual observations\rVideo Observations\rMicroscopic Observations\rVideos, time-lapses and microscopic observations\rA Brief History of Scientific Documentation Throughout the nineteenth and early twentieth centuries, biological illustrations were the primary means of documenting observations. Photography was still limited, so researchers attempted to reproduce what they saw as accurately as possible through scientific drawings. With the development of microphotography and later digital photography and videography, the situation fundamentally changed. Scientists could now preserve not merely their interpretation of an observation, but the observation itself. Modern technologies allow morphology, behavior, and dynamic biological processes to be documented with a level of completeness that was previously impossible. Scientific illustration has not lost its value. It helps emphasize diagnostic features, simplify complex structures, and direct the reader\u0026rsquo;s attention toward biologically important characteristics. This is precisely why the term scientific illustration exists—it is not a photographic copy of reality, but an interpretation created by the observer.\nHowever, a drawing used as the only evidence of an observation is fundamentally unverifiable.\nFor this reason, photographs and videos have become an essential part of scientific evidence rather than mere illustrations.\nIt is impossible to determine whether a drawing reflects an actual observation, the author\u0026rsquo;s interpretation, or imagination alone. Without primary documentation, a drawing ceases to function as evidence and becomes merely an assertion made by its author.\nModern scientific illustrations should therefore complement photographs and videos—not replace them.\nThe more extraordinary the conclusion, the greater the requirements for preserving the primary evidence. Why Does This Matter to Aquarists? Many people believe that microscopes are tools only for scientists.\nIn reality, they are valuable for anyone who wants to make observations rather than simply repeat other people\u0026rsquo;s conclusions.\nA photograph taken through the eyepiece, a video of parasite movement, or a series of images documenting the same specimen are not merely attractive illustrations. They are primary data that can be revisited months or years later, shared with colleagues, and compared with new observations.\nWithout them, every description gradually becomes a story.\nA microscope does more than allow you to see an object. It allows you to preserve an observation.\nQuestions and Answers I don\u0026rsquo;t own a microscope. Does this article still apply to me? Yes.\nThe principle applies to every kind of observation. Whenever it is possible to preserve photographs, videos, or other primary data, it should be done.\nDoes a photograph prove anything? No.\nA photograph records an observation. Scientific conclusions are supported by the combined evidence of independent observations, experiments, and critical analysis.\nWhat if no photograph exists? The observation itself does not lose its value. However, it becomes much more difficult for others to verify independently.\nWhat if the photographs contradict my conclusion? Even better.\nThe purpose of documentation is not to confirm the researcher\u0026rsquo;s expectations but to preserve what was actually observed. If primary evidence contradicts a conclusion, then the conclusion—not the evidence—should be reconsidered.\nAre scientific drawings no longer useful? They certainly are.\nScientific illustrations emphasize details that may be difficult to recognize in photographs. However, a drawing should never remain the sole evidence of an observation.\nWhy is this especially important for aquarists? Diseases disappear, fish die, medications are discarded—but photographs, videos, microscope slides, and preserved material remain. They allow us to return later and understand what truly happened.\nSee also ","permalink":"https://fossamethod.ru/en/posts/elephantfly/","summary":"Why an observation is not yet evidence. Why photographs, videos, and preserved material matter, and how to distinguish a convincing hypothesis from reproducible knowledge.","title":"Flying Elephants"},{"content":"\nWhat Counts as Evidence in the Age of Artificial Intelligence? Artificial intelligence does not eliminate flying elephants.\nIt helps them acquire a convincing explanation. Fossa From Storytelling to Documentation This article continues the idea introduced in Flying Elephants\rFlying Elephants\rWhy science requires more than an elegant hypothesis. The role of photographs, videos, specimens, and primary data in building and verifying …\r.\nAt first, knowledge was passed on as a story. Later came more formal descriptions: measurements, characters, Latin names, comparisons, diagnoses. Then biological illustration became a way to show the reader an organism they could not see for themselves.\nBut a drawing was still not the observation itself. It was the author\u0026rsquo;s reconstruction of an observation. When a drawing is the only record, it is fundamentally difficult to verify. Years later, we cannot know whether it represents a real observation, the author\u0026rsquo;s interpretation, or imagination.\nThen came photographs and videos. They did not make every conclusion automatically true, but they did make independent verification more realistic. A photograph preserves a moment; a video preserves a process.\nNot All Papers Are Documented Equally The problem of weak evidence did not begin with artificial intelligence.\nIn fish pathology, for example, one often sees the following logic:\na smear or culture was taken -\u0026gt; a bacterium grew -\u0026gt; therefore it caused the disease\rThe Smear Comes First.\rA reflection on why smear microscopy often matters more than bacterial culture in fish pathology. Real cases, logic, and the danger of …\r.\nBut there is a long distance between \u0026ldquo;a bacterium grew\u0026rdquo; and \u0026ldquo;this bacterium caused the death.\u0026rdquo; We need the clinical picture, photographs of lesions, tissue microscopy, inflammatory response, repeatability, exclusion of background microbiota, spatial association with the lesion, and in some cases experimental confirmation.\nIf those elements are missing, confidence in the conclusion should decrease. Not because the author is necessarily wrong, but because the reader is not given enough access to the original observation.\nThe absence of a photograph does not make a conclusion false.\nIt increases the share of trust placed in the author and reduces the share of independent verification.\nWhen a Drawing Replaces a Photograph For its time, biological illustration was a serious method of documentation. But in a paper where microphotographs, video, slide series, or preserved material are technically possible, a single drawing becomes a weak basis for an unusual conclusion.\nIn that situation the claim may be extraordinary, while the reader\u0026rsquo;s ability to verify it remains limited. This does not mean every such paper must be dismissed. But it is an ideal example of the problem: the more unusual the claim, the less it should depend on trust alone.\nThe more extraordinary the conclusion, the less it should rest on the author\u0026rsquo;s authority.\nWhen the Photograph Became a Drawing Again For a long time, scientific documentation developed in one direction: from a story toward material that could be shown to another person. A story could be retold. A drawing could be redrawn. But photographs and videos seemed closer to the event itself.\nFor nearly two centuries, each new documentation technology reduced the need to take the author\u0026rsquo;s word for it. Drawing gave way to photography; photography gave way to video. It seemed that the evidential foundation was becoming more reliable.\nGenerative AI has changed that familiar trajectory for the first time. Today it can create not only a story or a drawing, but also a photograph, a video, a voice, a table, a literature review, and a plausible explanation for an event that never happened.\nA high-quality photograph or video no longer guarantees that the observation actually occurred. In this sense, we have unexpectedly returned to a situation familiar to researchers of the early twentieth century: the image once again requires trust in its source.\nBack to the Future of Evidence 18th century \"I saw it\" Do you believe me? 19th century \"Here is a drawing\" Better 20th century \"Here is a photograph\" Excellent 21st century \"Here is a video\" Almost ideal AI era \"Here is a photograph\" Where did it come from? We have not returned to drawings. We have returned to the need to trust the author.\nParadoxically, technological progress has brought us close to the early twentieth century. Back then, a drawing required trust in the observer. Today, photographs and videos increasingly require the same kind of trust. We now sit with images and recordings much as earlier biologists sat with scientific drawings. This does not make AI an enemy of science. It simply makes the origin of data part of the evidence.\nThe Main Point At first, the weak point was the retelling. Then it was the author\u0026rsquo;s interpretation. Now the weak point has shifted toward the origin of the data.\nImage quality no longer guarantees observation quality.\nImage quality increasingly guarantees only image quality.\nText quality no longer guarantees evidence quality.\nThe quality of an explanation no longer guarantees that the object existed.\nArtificial intelligence has not made the scientific method unnecessary. On the contrary, it has reminded us why the method is needed\rScientific Method. A Practical Guide.\rHow knowledge is formed, why confidence often outpaces understanding, and how the scientific method helps distinguish observation from …\r.\nIn the past, it was often enough to ask: \u0026ldquo;Is there a photograph?\u0026rdquo; Now we also have to ask: \u0026ldquo;Where did this photograph come from?\u0026rdquo;\nIf video once reduced the distance between observation and reader, the video itself now needs a history of origin. Who recorded it? When? Where? On what object? Is there a sequence of original frames? Are there RAW files? Is there a specimen, a slide, an observation log, a repeated registration, or independent confirmation?\nThe evidence is no longer the image by itself. The evidence is the traceable path from the object to the image.\nMaterial evidence has not become less important. A microscope slide, fixed material, microbial culture, tissue sample, observation log, series of original images, or preserved object of study remains what it has always been: a way to return to the observation and examine it again.\nBut in a scientific article, the reader usually does not encounter the object itself. The reader encounters its representation: a photograph, a drawing, a table, a video frame, a description, or the author’s explanation. This is where the new question appears. If an image once helped bring the reader closer to the object, the image itself now needs a traceable origin.\nThe problem is not that material evidence has disappeared. The problem is that, in the public circulation of knowledge, it is increasingly not the object itself that circulates, but its persuasive digital shell.\nTherefore, evidence is no longer the image itself, but the ability to trace the path from the object to the image.\nScience spent a long time learning how to preserve observations. Now it also has to learn how to preserve the provenance of observations. FAQ Does this mean photographs and videos are no longer useful? No. They are still essential. But they should be treated as documented data, not as self-sufficient proof. Their value increases when the circumstances of recording, original files, sequence, specimen, or observation log can be checked.\nIs this only a problem for AI-generated images? No. AI makes the problem sharper, but the principle is older. Weak documentation, selective images, missing context, and overconfident interpretation existed long before generative AI.\nWhat should be preserved together with an image? As much context as possible: date, place, object, method, equipment, original files, repeated frames, related samples, microscopy slides, records, and any information that allows another person to reconstruct the path from observation to conclusion.\nCan a conclusion be correct even if the documentation is weak? Yes. A weakly documented conclusion can still be true. The problem is different: the reader has fewer ways to verify it independently and must rely more heavily on the author\u0026rsquo;s authority.\nWhat changes for scientific communication? Good communication is no longer just clear writing and strong visuals. It also requires provenance: showing where the data came from and how the conclusion was built from them.\n","permalink":"https://fossamethod.ru/en/posts/ai_forever/","summary":"A continuation of \u0026lsquo;Flying Elephants\u0026rsquo;: a story was never evidence, but now even photographs and videos need a documented origin. What counts as evidence in the age of artificial intelligence?","title":"What Is Your Evidence?"},{"content":"\nOriginally, I had no intention of creating a method, a philosophy, or a worldview. I was simply trying to understand questions that seemed incomplete.\nWhy did the fish die? Why did the treatment fail? Why can the same symptoms lead to different conclusions? Why do many explanations sound convincing while failing to explain the underlying mechanism? Why are some questions considered settled when, upon closer inspection, nobody can confidently explain the details? Over time, it became clear that these problems were not limited to fish pathology. They appear in science, education, engineering, medicine, management, and everyday life. Very often, the disagreement is not about facts but about the way people think. Not about what is known, but about how conclusions are reached.\nGradually, a set of principles emerged—principles that I repeatedly use when working with aquatic organisms, analyzing data, reading scientific literature, and building explanations. That collection of principles eventually became known as the Fossa Method.\nIn Brief Start with observation, not explanation. Do not confuse description with cause. Every system has constraints. Every model has limits. Simplicity should be the result of understanding. Complexity cannot be eliminated. Demystify knowledge. Look for contradictions. Respect the object of study. The story is more important than the answer. Understanding and knowledge must remain in balance. An explanation should open a door, not close a question. Authority does not replace mechanism. The origin of a claim does not replace its verification. An observed effect does not prove a single cause. I. Observation 1. Start with observation, not explanation The most common mistake is explaining a phenomenon before it has been properly described.\nExample.\rA fish is swimming near the surface and breathing heavily. That is an observation.\nThe statement \u0026ldquo;it has a bacterial infection\u0026rdquo; is already an explanation, and one that has not yet been supported by evidence.\nFirst describe the symptoms. Only then begin looking for their cause.\nStart with: \u0026ldquo;What happened?\u0026rdquo;, \u0026ldquo;What did we observe?\u0026rdquo;, \u0026ldquo;What did we measure?\u0026rdquo;, \u0026ldquo;What was recorded?\u0026rdquo;\nOnly afterwards ask: \u0026ldquo;Why did it happen?\u0026rdquo;\n2. Do not confuse description with cause Description is not explanation.\nExample.\rThe statement \u0026ldquo;the fish died from stress\u0026rdquo; does not explain the mechanism of death.\nWhat exactly happened?\nDid the fish stop feeding? Was there trauma? Failure of osmoregulation? Respiratory impairment? Some other process that can be observed and tested?\nThe real question is:\n\u0026ldquo;What mechanism produced the observed outcome?\u0026rdquo;\nII. Constraints 3. Every system has constraints A system is a collection of interconnected elements working together toward a particular goal.\nIn aquaculture, a system may be an aquarium, a filtration system, a population of fish, or even the organization of staff. Changing one element inevitably affects the others.\nExample.\rIncreasing stocking density allows more animals to be kept in the same volume of water, but it also increases the load on the filtration system and raises the risk of conflicts between individuals.\rConstraints cannot be eliminated.\nThey can only be redistributed.\nEvery solution creates new constraints.\nTherefore, the key question should always be:\n\u0026ldquo;What constraint are we trying to change, and what will appear in its place?\u0026rdquo;\n4. Every model has limits A model is a simplified representation of reality that helps us understand or predict the behavior of a system.\nEvery model discards some details in exchange for usefulness.\nModels can be mathematical, biological, engineering-based, or even verbal.\nExample.\rA medication may work effectively against one parasite while being completely ineffective against another. A method that solves one problem does not automatically become a universal solution.\nLikewise, the statement \u0026ldquo;fin rot is caused by bacteria\u0026rdquo; is a model that explains some cases of fin damage. However, it does not account for trauma, nutritional deficiencies, hemorrhage, or other factors that can produce similar changes. A model remains useful only as long as we remember its limits.\nThere are no universal solutions.\nThere are no medications that solve every problem.\nThere are no diagnostic signs that apply to every case.\nThere are no methods that work equally well under all conditions.\nThe question is not: \u0026ldquo;Does the model work?\u0026rdquo;\nThe more important question is: \u0026ldquo;Where does the model stop working?\u0026rdquo;\nIII. Understanding 5. Simplicity should be the result of understanding Example.\rThe statement \u0026ldquo;gas bubble disease is caused by excess dissolved gas\u0026rdquo; simplifies the phenomenon while preserving its mechanism.\nThe statement \u0026ldquo;gas bubble disease is caused by bubbles in the water\u0026rdquo; sounds simpler, but it distorts the process itself.\nSimplification is useful.\nOversimplification is dangerous.\nA good explanation:\nremoves unnecessary details; preserves what is essential; reveals the mechanism. A poor explanation:\nremoves the mechanism itself. 6. Complexity cannot be eliminated Example.\rSome parasites can be identified using nothing more than a microscope and a simple smear. However, determining the exact nature of certain diseases may require additional investigations. Simplicity is valuable only when it does not distort reality.\rSome things are genuinely complex.\nIf the object itself is complex, the description may also need to be complex.\nComplexity is not a flaw.\nPretending complexity does not exist is.\n7. Demystify knowledge Example.\rZiehl–Neelsen staining may appear to be a complicated laboratory procedure. In reality, its purpose can be reduced to two steps: stain the target structure and then remove the stain from surrounding tissues while retaining it within mycobacteria.\rComplex terminology does not make an idea profound.\nTerminology exists for precision, not for authority.\nKnowledge should become more accessible, not more mysterious.\nIV. Inquiry 8. Look for contradictions Example.\rIf every sign points toward a bacterial disease but bacteriological testing fails to confirm it, that contradiction becomes the reason to reconsider the original hypothesis.\rThe most interesting observations are not confirmations.\nThe most interesting observations are those that do not fit the existing picture.\nThey are what move understanding forward.\n9. Respect the object of study Example.\rA poorly performed necropsy can destroy evidence before it is ever examined. Careful work preserves information that may later become essential for understanding the cause of death.\rA fish is not a statistical unit.\nA stain is not a ritual.\nA necropsy is not a formality.\nEvery observation is a source of information.\nThe goal of the investigator is not to confirm a preferred explanation, but to understand what actually happened.\nV. Growth 10. The story is more important than the answer Example.\rKnowing that physicians eventually began washing their hands before surgery is useful. Understanding which observations led to that conclusion—and why the idea was resisted for so long—is even more valuable.\rA final conclusion is useful.\nBut it is often more useful to understand:\nhow that conclusion was reached; which mistakes were made; which alternatives were considered; why some ideas failed while others survived. The history of discovery is often more valuable than the result itself.\n11. Understanding and knowledge must remain in balance Example.\rIt is possible to memorize the life cycle of a parasite without understanding its significance. It is equally possible to speculate about parasites without knowing their biology. Knowledge becomes useful only when facts and understanding support one another.\rKnowledge without understanding becomes memorization.\nUnderstanding without knowledge becomes imagination.\nGrowth requires both.\n12. An explanation should open a door, not close a question Example.\rA good explanation allows a person to take the next step independently. It provides a working model without creating the illusion that the subject has been exhausted.\rA poor explanation says:\n\u0026ldquo;It\u0026rsquo;s simple. Memorize it and stop thinking.\u0026rdquo;\nThe opposite extreme says:\n\u0026ldquo;It\u0026rsquo;s so complicated that you shouldn\u0026rsquo;t even try.\u0026rdquo;\nBoth positions are equally harmful.\nA good explanation sounds more like:\n\u0026ldquo;Here is the simplest model that allows you to begin understanding the phenomenon. It is not the whole picture.\u0026rdquo;\nAn explanation should be simple enough to provide an entry point and honest enough to acknowledge that deeper levels of understanding still exist.\n13. Authority does not replace mechanism Example.\rAn expert opinion has value, but its value increases when it is possible to understand which observations, data, and reasoning led to that conclusion.\rA position is not evidence.\nExperience alone is not evidence.\nA publication record is not evidence.\nIf a mechanism cannot be explained, authority does not make the explanation correct.\n14. The origin of a claim does not replace its verification. Example.\rThe fact that a claim comes from a teacher, a specialist, an organization, or is widely accepted within a professional community does not prove that it is true. The source may increase confidence in the claim, but it does not exempt the claim itself from verification.\r15. An observed effect does not prove a single cause. Example.\rThe fact that a particular cause can produce an observed sign does not mean that the presence of that sign confirms this cause. Toxic exposure may damage the gills, but damaged gills alone do not prove toxicosis.\rQuestions and Answers Is this a new scientific method? No.\nThe scientific method existed long before me and works perfectly well on its own.\nFossa Method is not a replacement for the scientific method. It is an attempt to articulate a set of principles that help formulate questions, build explanations, and distinguish observations from interpretations.\nIs this a philosophy? Not really.\nIt is a collection of practical observations that gradually emerged while working with aquatic animals, diagnosing diseases, analyzing data, and studying the history of science.\nWhy not simply use the scientific method? The scientific method asks:\nHow do we test hypotheses?\nFossa Method more often asks:\nHow do we decide which question is worth asking in the first place?\nWhy is there so much emphasis on constraints? Because many mistakes arise not from a lack of solutions, but from ignoring limitations.\nEvery solution improves something while creating new problems elsewhere.\nWhy so much emphasis on observation? Because explanations often arrive before observations.\nPeople see a phenomenon and immediately assign a cause.\nThere should always be a pause between observation and explanation.\nWhat exactly did we observe?\nWhy criticize authority? I do not criticize authority.\nI criticize situations where authority replaces explanation.\nExperience, expertise, and qualifications matter.\nBut neither position nor reputation constitutes evidence by itself.\nWhy does a fish-related website contain a page about thinking? Because most articles on this site did not begin with answers.\nThey began with questions that felt incomplete.\nOver time, it became clear that the same principles apply not only to fish pathology, but also to engineering, medicine, programming, education, and scientific research.\nWhat is the core principle of Fossa Method? If I had to choose only one, it would be:\nDo not start with an answer. Start with a question.\n","permalink":"https://fossamethod.ru/en/posts/fossa-method/","summary":"Not answers, but principles for finding them.","title":"Fossa Method"},{"content":"\nIntroduction The question “how do you know that?” can be irritating.\nNot because it is wrong — but because it is difficult to answer honestly.\nIn most cases, the answer sounds confident, but is based not on verification, but on habit, experience, or someone else’s conclusions.\nThe problem is not that we don’t know.\nThe problem is that we don’t know — and yet we are confident that we do.\nHow knowledge is formed Knowledge does not appear as a finished answer.\nIt is assembled gradually — from observations, errors, and attempts to explain what is seen.\nThe history of science is not a sequence of discoveries, but a chain of refinements.\nNew data rarely overturn everything at once. More often, they reveal the limitations of previous explanations.\nEven simple questions may require years of observation and verification.\nSometimes — a lifetime.\nWhat we often mistake for knowledge what “everyone says” what “has always been done” what resembles a familiar case what conveniently explains what we see All of these can be useful.\nNone of them, by themselves, constitute evidence.\nThe most dangerous error is not the absence of knowledge,\nbut confidence in an explanation that has not been tested.\nThis becomes especially evident in fish pathology The same symptom may have different causes.\nSimilar changes may arise from entirely different processes.\nThe presence of a sign does not imply understanding of the mechanism.\nGas bubbles are not always gas bubble disease.\nWhite spots are not always the same parasite.\nHyperemia is not always inflammation.\nWithout a method, observation easily turns into speculation —\nand speculation into confident explanation.\nWhat the scientific method is in practice The scientific method is not a formula or a set of terms.\nIt is a way of working with reality.\nIt includes:\nobservation recording conditions comparison of signs testing alternative explanations rejecting convenient explanations when they fail under scrutiny It does not guarantee the correct answer.\nBut it reduces the likelihood of being confidently wrong.\nWhat changes with this approach fewer “instant diagnoses” less ritual treatment better understanding of causes rather than symptoms greater caution in conclusions Most importantly, it allows distinguishing observation from interpretation.\nThe scientific method does not make the work easier — it makes it more honest.\nIt does not eliminate errors — but it prevents them from going unnoticed.\nIt is not a way to always be right — it is a way to avoid being confidently wrong.\nCore principles The method does not begin with an answer.\nIt begins with observation.\n1. Data collection Observation must be separated from interpretation.\nRecord what is actually observed:\nfish behavior external appearance changes over time environmental conditions Do not explain — describe.\nNot “the fish is sick”, but “the fish is lying on the bottom, respiration is increased”.\n2. Recording conditions Every observation has context. Without it, data lose meaning.\nRecord:\ntemperature water parameters system changes feeding transfers, stress The same symptom under different conditions represents different situations.\n3. Keeping records Memory distorts sequence. Records do not.\nRecord:\nwhat happened when under what conditions what changed after intervention Without records, it is impossible to distinguish cause from consequence.\n4. Comparing signs A single sign does not constitute a diagnosis.\nMeaning arises from their combination.\nCompare:\nwhich signs match which contradict what is missing despite expectations The absence of a sign can be more important than its presence.\n5. Testing alternatives The first explanation is usually the most convenient.\nAnd often wrong.\nAsk:\nwhat else could explain this?\nIf at least one alternative exists, it must be considered.\n6. Minimal intervention Intervention changes the system — sometimes faster than we can understand it.\nThe more simultaneous actions:\nthe harder it is to identify the cause the higher the risk of incorrect conclusions Fewer actions, but with understanding of their effect.\n7. Evaluating outcomes Every action is a hypothesis. The result is its test.\nImprovement does not always mean the cause was identified.\nLack of improvement does not always invalidate the hypothesis.\nEvaluate:\nwhat changed how quickly how stable the effect is Important The method is not a sequence of steps to complete.\nIt is a way of thinking applied at every stage.\nIt does not require complex equipment.\nIt requires accuracy in observation and honesty in conclusions.\nThis is what distinguishes knowledge from assumption.\nReferences Ferguson, H.W., 2006. Systemic Pathology of Fish: A Text and Atlas of Comparative Tissue Responses in Diseases of Teleosts, 2nd ed. Scotian Press, London. Kuhn, T.S., 2012. The Structure of Scientific Revolutions, 4th ed. University of Chicago Press, Chicago. Noga, E.J., 2010. Fish Disease: Diagnosis and Treatment, 2nd ed. Wiley-Blackwell, Ames. Popper, K.R., 2002. The Logic of Scientific Discovery. Routledge, London. FAQ Why is one symptom not enough for diagnosis? Because the same sign may result from different processes.\nWhat matters more: experience or method? Method. Experience without verification often leads to errors.\nWhy avoid immediate treatment? Because intervention alters the system and obscures the cause.\nWhat does “testing alternatives” mean? Considering other possible explanations, not just the first one.\nCan mistakes still occur? Yes, but the method reduces confident errors.\n","permalink":"https://fossamethod.ru/en/posts/science/","summary":"A practical view of the scientific method: how to avoid being confidently wrong and distinguish knowledge from assumption.","title":"Scientific Method. A Practical Guide."},{"content":"\nDepth of analysis F. F.O. F.O.S. Knowing the limitations of a method does more than protect us from incorrect conclusions — it tells us where and how to look for what we cannot yet see. Fossa Ziehl–Neelsen without the full set of reagents: what can we still learn? If you have a fully equipped laboratory, all the necessary reagents and suitable working conditions, the answer is straightforward: to test bacterial acid-fastness, perform a standard Ziehl–Neelsen stain.\nThis article is not about replacing the standard method when it is available.\nIt deals with another situation, one much more familiar in small fish farms, public aquariums, among fish pathologists without a dedicated bacteriology laboratory, and even among aquarists who own a microscope. There is a diagnostic question and a specimen ready to examine, but not the complete set of reagents.\nPhenol is toxic, unpleasant to handle and requires appropriate storage and working conditions.\nStrong mineral acids are not exactly substances you would want to keep next to your microscope “just in case.” They must be purchased, stored and handled with appropriate safety measures.\nIf part of the classical procedure is unavailable, does that mean the specimen can no longer provide useful information?\nYou can treat what follows as a little methodological experiment: remove one step, substitute another and see what changes. Or you can treat it as a practical necessity.\nEither way, the principle is the same:\nUnderstand what each step actually does, what we learn from it, and what we can no longer conclude when that step is removed or modified.\nWhat does the classical method actually do, and where did it come from? Loeffler staining Ziehl–Neelsen staining In this smear, simple staining reveals rod-shaped structures less clearly than the specialized stain.\nZiehl–Neelsen staining is used to detect acid-fast bacteria, including mycobacteria (World Health Organization, 1982). However, a positive stain does not identify a bacterial genus.\nInterestingly, the procedure we know today did not emerge all at once. What we call “Ziehl–Neelsen staining” took shape over a remarkably short period through successive changes to existing staining methods (Vilchèze \u0026amp; Kremer, 2017).\nIn March 1882, Robert Koch, presenting his work on the causative agent of tuberculosis, described staining specimens with a hot alkaline solution of methylene blue, followed by counterstaining with vesuvin (Bismarck brown). Mycobacteria appeared blue against a brown background (Vilchèze \u0026amp; Kremer, 2017).\nIn May of the same year, Paul Ehrlich modified the method. Instead of methylene blue, he used fuchsin or methyl violet in saturated aniline water, then decolorized the specimen with 30% nitric acid and applied a counterstain (Vilchèze \u0026amp; Kremer, 2017).\nFranz Ziehl took the next step. In August 1882, he replaced aniline oil with carbolic acid (phenol). The resulting carbol fuchsin solution proved more stable than Ehrlich\u0026rsquo;s aniline-based preparation (Vilchèze \u0026amp; Kremer, 2017).\nIn October 1882, Eduard Rindfleisch proposed heating the specimen directly during staining.\nThen, in July 1883, Friedrich Neelsen published his modification of Ziehl\u0026rsquo;s method: 0.75% fuchsin in 5% carbolic acid, followed by decolorization with 25% sulfuric acid (Vilchèze \u0026amp; Kremer, 2017).\nSo phenol did not enter the method as an immutable part of some original recipe.\nZiehl introduced it in place of aniline, Rindfleisch added heat, and Neelsen modified the dye composition and decolorization conditions.\nWithin roughly sixteen months, Koch\u0026rsquo;s original technique had undergone several substantial changes. Only later did the procedure become established under the familiar name Ziehl–Neelsen staining (Vilchèze \u0026amp; Kremer, 2017).\nAnd its development did not stop there.\nIn 1887, Gabbett attempted to shorten the procedure by combining acid decolorization with counterstaining. In 1915, Joseph Kinyoun proposed a “cold” method without heating: the fuchsin concentration was increased to approximately 3.1%, phenol to 6.25%, and 3% hydrochloric acid was used as the decolorizer (Vilchèze \u0026amp; Kremer, 2017).\nEven historically, the method developed in precisely this way:\nThe objective remained the same, while the means of achieving it changed: reagents were replaced, concentrations adjusted and treatment conditions modified.\nWhat is considered the classical procedure today? Modern versions use heated carbol fuchsin, followed by acid or acid-alcohol decolorization and a contrasting counterstain (World Health Organization, 1982) (World Health Organization, 1999).\nOne decolorizing formulation is 3% acid-alcohol:\n3 mL of concentrated hydrochloric acid + 97 mL of 95% ethanol.\nIn this formula, “3%” denotes the conventional volume ratio of the starting concentrated acid to alcohol, not the precise mass fraction of pure HCl (World Health Organization, 1998).\nThis is not Neelsen\u0026rsquo;s original formulation. His 1883 version used 25% sulfuric acid.\nThe same applies to the primary dye. Neelsen used 0.75% fuchsin in 5% phenol. The composition was subsequently modified many times: Vilchèze and Kremer describe 0.3% fuchsin and 5% phenol for one modern ZN formulation, and considerably higher concentrations for Kinyoun\u0026rsquo;s cold method (Vilchèze \u0026amp; Kremer, 2017).\nThis matters for understanding the method:\nThere is no single concentration forever fixed by the name “Ziehl–Neelsen.” There is a purpose behind each operation, and a set of conditions under which it produces a reproducible result.\nKnowing a method\u0026rsquo;s limitations means being able to work with them If you see the method as a recipe, it is simple:\nfuchsin → heat → acid → counterstain.\nBut when we ask why each step is performed, the picture becomes more interesting:\ncarbol fuchsin provides intense primary staining; phenol and heating help the dye penetrate structures that are difficult to stain; acid decolorization tests whether stained structures can retain fuchsin; counterstaining makes the background easier to examine under a microscope. Removing one step therefore does not necessarily make the entire result useless.\nSome observations remain valid, but certain conclusions can no longer be drawn.\nKnow the limits of a method, and you can work with them.\nIgnore those limits, and all you can do is follow a recipe.\nIf we cannot see bacteria, we do not know whether they are absent from the tissue or simply not detected by the staining method used.\nIf staining makes them visible, that is already an observation. We can examine their shape, number, distribution and association with pathological lesions.\nBut what the observation actually proves depends on how we obtained the image. We can see red rods; whether those rods would retain fuchsin after acid treatment is a separate question.\nAcid-fast does not necessarily mean Mycobacterium Branching bacterial clusters There is another trap: detecting acid-fast rods does not mean that you have necessarily found Mycobacterium. Fish pathogens also include Nocardia — actinomycetes capable of causing granulomatous lesions in internal organs (Maekawa et al., 2018).\nNocardia may appear as long rods, filamentous structures or branching clusters. They exhibit partial, or variable, acid-fastness: under milder decolorization conditions, some cells retain fuchsin, while stronger treatment may remove the stain. Intensely and weakly stained segments can coexist in a single specimen. This property is assessed by the outcome of the staining procedure, not by how long, curved or branched a rod happens to look (Brown-Elliott et al., 2006).\nIn the study by Del Rio-Rodriguez and colleagues, branching acid-fast bacteria found in red drum were identified as Nocardia seriolae. The authors demonstrated the organisms using several staining techniques and confirmed their identity by molecular methods (Del Rio-Rodriguez et al., 2021). Importantly, Nocardia may retain stain even with the Ziehl–Neelsen procedure; such a result cannot automatically be attributed to mycobacteria. Yet without identification, the reverse assumption is equally unjustified: we cannot claim that most large rods must be nocardia.\nZiehl–Neelsen staining reveals a property of stained structures, not their genus. Branching is a reason to investigate Nocardia, not proof of nocardiosis. Granulomas, bacterial size and a “broken” or beaded staining pattern are not enough, by themselves, to distinguish between these diagnoses.\nWhat if phenol is unavailable? Phenol is included in classical carbol fuchsin for a reason. Traditionally, it is thought to facilitate dye penetration through the lipid-rich cell envelope of mycobacteria. Heating also promotes staining.\nBut is fuchsin really unable to penetrate bacteria without phenol?\nResearchers tested this experimentally long before my own attempts — and, interestingly, some of those experiments involved pathogens of fish.\nIn 2000, Vinnie Della Speranza and Rena Fail published a paper with a particularly expressive title: “Phenol Myth Unveiled! Were Ziehl-Neelsen and Kinyoun Mistaken?”\nThe authors first tried replacing phenol with surfactants. They then investigated what would happen if those were removed as well, leaving only an aqueous solution of basic fuchsin.\nThe result was unexpected: a 0.5% aqueous fuchsin solution heated to 60 °C for 15 minutes stained mycobacteria well. At room temperature, the same solution remained ineffective even after an hour. The paper includes micrographs of Mycobacterium avium and M. tuberculosis stained without phenol (Della Speranza \u0026amp; Fail, 2000).\nThus, omitting phenol does not necessarily prevent staining. But the conditions under which the dye is applied do matter.\nIn 2008, Carol McCollough tested this approach directly on pathogens of fish and aquatic invertebrates.\nShe used 0.5% aqueous fuchsin at 60 °C for 15 minutes, followed by acid-alcohol decolorization. The procedure revealed M. marinum in a goldfish kidney and M. chesapeaki in the spleen of a striped bass.\nThe study was not limited to mycobacteria. Positive staining was also obtained with several microsporidian, haplosporidian and myxosporean organisms. Not all targets stained equally well: for instance, fixed spores of Kudoa clupeidae failed to retain fuchsin after decolorization (McCollough, 2008).\nIn other words, a phenol-free method has already been used in fish pathology to detect mycobacteria in fish tissues, including spleen specimens.\nIn 2020, Gomes and colleagues conducted another comparative study and proposed a modification called GASMoC.\nUnlike the earlier experiments, this method used 1% aqueous fuchsin at only 37 °C for 15 minutes. Specimens were stained in parallel: some with conventional carbol fuchsin and others without phenol. Both groups then underwent the same acid-alcohol decolorization.\nOf twelve samples with previously established tuberculosis, GASMoC detected acid-fast bacteria in all twelve, compared with eleven using the conventional Ziehl–Neelsen technique. All seven negative controls remained negative with both methods.\nThe researchers found no statistically significant difference between the methods. In fact, rods stained by GASMoC were often more intensely colored and easier to distinguish from surrounding tissue.\nThe paper presents directly comparable micrographs, with phenol in one procedure and without it in the other. The authors also successfully tested the method on zebrafish tissue containing Mycobacterium marinum (Gomes et al., 2020).\nThus, phenol was not essential for detecting acid-fast bacteria in the specimens examined. Changing the composition of the primary dye did not eliminate a diagnostically useful result.\nOne detail is especially important here: all three studies retained the acid-decolorization step. The authors omitted phenol, but continued to test fuchsin retention after acid treatment.\nSo this is not merely about seeing red rods without phenol. It is about detecting acid-fast structures using a modified primary stain.\nOf course, that does not mean any staining procedure can be modified arbitrarily and expected to produce identical results. It does show that the same diagnostic property can be demonstrated under different staining conditions.\nIf phenol helps a dye enter a bacterium, that does not mean entry is impossible without it. The question is not whether a particular reagent is indispensable, but whether the required result can be achieved without it.\nIf phenol is unavailable, we need not ask:\n“How can we pretend that we are still performing Ziehl–Neelsen?”\nInstead, we can ask:\nCan we stain the structures of interest sufficiently well by another means?\nIn my own specimens, intense heating with fuchsin but without phenol made red rod-shaped bacteria clearly visible. This does not prove that phenol and heat are completely interchangeable. Nor does it turn such a procedure into classical Ziehl–Neelsen staining. But something important did happen for the practical task at hand:\nBacteria that had previously been difficult to distinguish became visible.\nWe can assess their morphology, abundance and distribution within the tissue. That is already useful information.\nWhat if acid is unavailable? Here the boundary is even clearer. It is acid decolorization that establishes the property behind the term “acid-fast”: following differentiation, some structures lose fuchsin while others retain it. Therefore, if the specimen has not undergone acid decolorization, we cannot claim:\n“Acid-fast bacteria were detected.”\nAcid-fastness was simply not tested. But that does not make everything done beforehand meaningless. If intensive staining reveals numerous clearly distinguishable rod-shaped bacteria in tissue material, we already know they are present. We can see their shape, the density of their clusters, their distribution and their relationship to pathological changes.\nWe simply do not yet know one more property — whether they would retain fuchsin after acid differentiation. And those are fundamentally different things.\nBrightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off After intensive fuchsin staining, the specimen can be counterstained. In my case, I used Loeffler\u0026rsquo;s counterstain. The rods that had stained intensely before remained bright red.\nThis contrast makes rod-shaped bacteria easy to see. But by itself, it is not a test for acid-fastness.\nNor does it justify calling every visible rod a mycobacterium: without genus-level identification, Nocardia and other bacteria with similar morphology cannot be excluded.\nAnd this opens up another possibility that is easily overlooked if acid is treated as a mandatory part of every fuchsin stain. Without acid decolorization, we see more than just structures capable of surviving acid treatment. Other bacteria, spores, parasite oocysts and various tissue structures may also remain stained. Sometimes that is a disadvantage: the background becomes denser and the specimen harder to interpret. At other times, this broader picture is exactly what we need.\nBy omitting acid decolorization, we lose selectivity for acid-fastness, but we may reveal structures that the omitted step would have made invisible.\nThis is not an invented approach. For example, modified acid-fast stains using fuchsin are employed to detect oocysts of Cryptosporidium, Cyclospora and Cystoisospora. These are parasites, not fungi. In standard versions, acid decolorization is generally modified rather than omitted; staining can be variable, and some oocysts remain entirely unstained (CDC, n.d.) (CDC, n.d.).\nBacterial endospores are another example. Dorner\u0026rsquo;s staining method uses heated carbol fuchsin; one modification dispenses with a separate acid-decolorization step. It is not a stain for mycobacteria, but a way to demonstrate a different structure with a familiar dye (American Society for Microbiology, 2016).\nSo the question is not always how to make a stain “correct” for one particular pathogen. Sometimes it is more useful to reveal a wider range of structures, assess their morphology and distribution, and then decide which findings need specific confirmation.\nOne organ — three staining methods\nFor this comparison I used material from the spleen of a freshwater angelfish, which contained numerous pale lesions.\nHere is a gross photograph of the spleen.\nThree sets of specimens were prepared from this material using different procedures:\nWithout phenol or acid decolorization. Without phenol, but with decolorization using 5% sulfuric acid. With phenol, followed by acid decolorization. The same microscope and camera were used throughout.\nPhenol and acid No phenol; acid decolorization Neither phenol nor acid\nThe result was interesting: rod-shaped bacteria of similar morphology were clearly visible in all three preparations. Staining was retained even after treatment with 5% sulfuric acid in the absence of phenol.\nIn separate earlier experiments, I had observed rods retaining the stain even after thirty minutes of treatment with 10% sulfuric acid.\nNaturally, three specimens from one organ do not constitute a full comparative study of staining sensitivity. They do, however, provide direct evidence that removing phenol does not necessarily prevent staining of the bacteria we are trying to examine.\nThis raises the central question: if the required result can be obtained after changing the reagent composition, which parts of the procedure are essential and which are merely one way of achieving the objective?\nThat does not make phenol useless or the three procedures equivalent. It means the results can be investigated, compared and evaluated rather than merely checked against a recipe.\nHere is another example. In a different specimen, we replace fuchsin with an aqueous solution of malachite green, perform acid decolorization, and counterstain with phloxine.\nMalachite green with heating, 5% sulfuric acid for two minutes, phloxine. Carbol fuchsin followed by acid decolorization\nDo you see any similarity in morphology?\nMalachite green, acid decolorization, phloxine. Both preparations show elongated rod-shaped structures, sometimes forming characteristic clusters. The colors, contrast and staining patterns differ, but similarities in shape and arrangement are readily apparent.\nWe have replaced not only phenol, but the primary dye itself. Yet the morphological features of interest remain available for observation.\nOf course, similarity between images does not prove that different specimens contain the same microorganisms. It shows that useful morphological information can be obtained by different means.\nNow another question: does every diagnostic task really require Ziehl–Neelsen staining?\nSometimes the immediate task is not to confirm a particular bacterial property but to detect suspicious structures, examine their morphology and decide what to investigate next.\nCan you find rod-shaped structures without color?\nSelect the squares where you think rod-shaped structures are present. Then reveal the color image. Reveal color Reset Does it have to be that particular acid? Even the history of the classical method shows that the important thing is not the “magic” of one particular acid, but how it decolorizes the specimen and whether the structures of interest retain their stain.\nDifferent acid-fast staining procedures use different reagents and concentrations for differentiation: for example, sulfuric acid at various concentrations or acid-alcohol containing HCl (\rWorld Health Organization, 1982; World Health Organization, 1999). WHO materials have also mentioned hydrochloric, sulfuric and nitric acids (World Health Organization, n.d.).\nThe purpose of acid treatment is to distinguish structures that readily lose their stain from those that retain fuchsin under the chosen conditions. But changing the acid, its concentration or the exposure time does not automatically produce an equivalent diagnostic test.\nThat leads to a perfectly reasonable experimental question:\nWhat would happen if we replaced the usual decolorizer with a concentrated citric acid solution? Which structures would lose their stain, and which would retain it?\nIf the background becomes decolorized while some rods remain red, that is an interesting experimental result. But this observation alone does not establish acid-fastness by a standard criterion.\nImportant: this is an experimental substitution of a reagent, not a validated variant of Ziehl–Neelsen staining. Citric acid is not listed as a standard decolorizer in the reference procedures reviewed here; equivalence would need to be evaluated using control specimens.\nThe concentration is therefore not a sacred number in a recipe. The type of acid and duration of treatment matter as well. With mild treatment, the surrounding tissue may retain fuchsin; if your objective is simply to see the rods, that is not always a problem. With harsher treatment, even the bacteria of interest may lose their stain. We need to understand exactly what the rods withstand rather than treating any residual red staining as proof of the same property.\nThe task is not to find a universally “correct” acid concentration. It is to understand what happens as the decolorization conditions become more or less stringent.\nEven acid-fastness is not an unchanging property Mycobacteria are often described as acid-fast bacteria, as though every cell always retained the dye equally well. But even within one genus, the expression of this property can vary.\nThe situation is not quite that simple.\nVilchèze and Kremer discuss the so-called “Koch paradox”: when Mycobacterium tuberculosis enters a persistent, nonreplicating state, some bacilli may become ZN-negative — no longer detectable by standard acid-fast staining (Vilchèze \u0026amp; Kremer, 2017). Such a state is often called dormant, or “sleeping,” although the bacteria are not literally asleep.\nThis has been associated with changes in lipid metabolism and cell-envelope structure. The exact mechanism behind the loss of acid-fast staining is not yet fully established: envelope changes may hinder dye penetration or reduce dye retention after decolorization.\nHere, knowledge of Koch\u0026rsquo;s paradox suggests a simple practical approach. Imagine a familiar situation: the spleen or kidneys contain numerous granulomas, the findings resemble mycobacteriosis, but no rods are detected by Ziehl–Neelsen staining. What next? We could stain the material again with fuchsin, this time without acid decolorization.\nPerhaps we would see the same irregular, unevenly stained rods of familiar morphology that were not visible after acid treatment. We would not have proved that they are mycobacteria, but we would have obtained another observation and a new direction for investigation.\nThis is not an attempt to “fix” a negative Ziehl–Neelsen result at any cost. We are simply using another staining approach: first examining morphology without selection by acid retention, then comparing what we find with changes in the tissue. Omitting acid broadens the range of visible structures, so a familiar bacterial shape alone does not become a diagnosis.\nVilchèze and Kremer\u0026rsquo;s work primarily concerns M. tuberculosis. It is good reason not to treat a negative ZN stain as proof that mycobacteria are absent, but it does not justify explaining every ZN-negative granuloma in a fish as dormant mycobacteria.\nProperly performed Ziehl–Neelsen staining does not answer “Are there any mycobacteria here at all?” It answers a narrower question: “Are there structures here that demonstrate acid-fast staining under these conditions?”\nThe practical implication is significant.\nIf rod-shaped bacteria retain their stain after acid differentiation performed according to an established procedure, we observe acid-fastness under those conditions — but we have not yet identified their genus or species.\nIf no bacteria are detected by ZN staining, that does not yet prove that mycobacteria are absent from the specimen.\nDuring persistent infection, part of the bacterial population may remain undetectable by conventional acid-fast staining, potentially leading to an underestimate of bacterial burden (Vilchèze \u0026amp; Kremer, 2017).\nA stain does not reveal a bacterium\u0026rsquo;s name. It reveals how that bacterium responds to a particular procedure.\nThis is where understanding the limitations of a method becomes especially important.\nWe see rods — we know that rod-shaped bacteria are present in the tissue.\nWe perform acid decolorization according to an established method, and the rods retain their stain — we observe acid-fastness under those conditions, but still do not know their genus or species.\nZiehl–Neelsen gives a negative result — we still do not know whether mycobacteria are absent from the tissue.\nWhat do we actually know in the end? Imagine a specimen in which heating with fuchsin makes numerous thin red rods clearly visible.\nIf their morphology allows us to distinguish them confidently as rod-shaped bacteria, we can describe their presence in the material examined. But not everything that takes up fuchsin is necessarily a bacterium: other structures may also be present in the specimen.\nWe can assess:\ntheir shape and size; how they are arranged; their number and the density of clusters; the tissue context; their association with granulomatous or other pathological changes; whether the finding is repeated in different areas of the material. Morphology alone does not identify a bacterial genus, let alone a species.\nBut the absence of complete identification does not make an observation useless.\nSeeing bacteria and identifying their species are two different diagnostic tasks.\nLikewise:\nSeeing stained bacteria and demonstrating acid-fastness are also two different tasks.\nIf greater certainty is needed, the next step may be a complete acid-fast staining procedure, culture, PCR or another confirmatory method.\nBut if none of those options is currently available, that is no reason to pretend the microscope showed nothing at all.\nWhere is the “tradition instead of science” in all this? The standard method itself is not the problem.\nA standard method is valuable precisely because its conditions are defined, tested and reproducible.\nThe problem begins when we stop asking why each step is performed and simply repeat the familiar sequence like a ritual:\n“Without phenol, you cannot see anything.”\n“You must use this particular acid because the protocol says so.”\n“If one step is missing, the entire result automatically becomes worthless.”\nA scientific approach asks a different question:\nWhat exactly changed in the result when we changed the method?\nIf you do not understand what a stain actually demonstrates, you may never even think to examine the material differently. When you do not recognize the limits of your knowledge, you also fail to see the questions that remain to be asked.\nIf we omit acid decolorization, we lose the grounds for claiming acid-fastness, but we do not necessarily lose diagnostic information.\nIn fact, we may see structures that acid treatment would otherwise have made invisible.\nIf we change the staining conditions, we examine whether the desired image can still be obtained.\nIf we substitute the acid, we test which structures become decolorized and what conclusions the result supports.\nSometimes modifying a method narrows the range of defensible conclusions while expanding the range of things we can observe. The boundary is not between a “correct” and an “incorrect” ritual, but between what was actually tested and what we merely assume.\nYou can modify a method. But when you do, the limits of what you can legitimately conclude change as well.\nHow should the result be described? If the classical procedure was not performed in full, we cannot simply call it by the classical name.\nYou can say:\n“A modified heated fuchsin stain without acid decolorization was used. Intensely stained rod-shaped bacteria were observed in the tissue material. Their acid-fastness was not assessed.” You cannot say:\n“Ziehl–Neelsen staining was performed; acid-fast bacteria were detected.”\nThese are different claims.\nIf acid-fastness has actually been tested, a suitable description is “acid-fast rod-shaped bacteria (branching where observed) were detected.” Identifying them as “mycobacteria” or “nocardia” requires further evidence.\nConclusion Knowing a method\u0026rsquo;s limitations means being able to work with them.\nIf a method has been modified, we should neither present it as the standard procedure nor automatically dismiss the resulting information as useless. Sometimes omitting one step costs us diagnostic selectivity, but allows us to notice something we could not previously see.\nThe task is much simpler:\nState precisely what we did, what we saw and what actually follows from it.\nReferences Maekawa, S., Yoshida, T., Wang, P.-C., Chen, S.-C., 2018. Current knowledge of nocardiosis in teleost fish. Journal of Fish Diseases, 41(3), 413–419. A review of fish nocardiosis and the granulomatous lesions associated with Nocardia infection.\nhttps://doi.org/10.1111/jfd.12782\nBrown-Elliott, B.A., Brown, J.M., Conville, P.S., Wallace, R.J., 2006. Clinical and Laboratory Features of the Nocardia spp. Based on Current Molecular Taxonomy. Clinical Microbiology Reviews, 19(2), 259–282. Describes branching forms, variable acid-fastness and modified staining with milder decolorization.\nhttps://doi.org/10.1128/CMR.19.2.259-282.2006\nDel Rio-Rodriguez, R.E. et al., 2021. First evidence of fish nocardiosis in Mexico caused by Nocardia seriolae in farmed red drum (Sciaenops ocellatus, Linnaeus). Journal of Fish Diseases, 44(8), 1117–1130. Figure 4 shows branching and unevenly stained structures; N. seriolae was confirmed by PCR and sequencing.\nhttps://doi.org/10.1111/jfd.13373\nCenters for Disease Control and Prevention (CDC), n.d. DPDx — Stool Specimens: Staining Procedures.\nDescribes modified acid-fast stains for oocysts of Cryptosporidium, Cyclospora and Cystoisospora. They use fuchsin and differentiation but differ from classical Ziehl–Neelsen staining.\nhttps://www.cdc.gov/dpdx/diagnosticprocedures/stool/staining.html\nCenters for Disease Control and Prevention (CDC), n.d. DPDx — Cryptosporidiosis.\nIllustrates oocysts after modified acid-fast staining and notes variable staining, including almost completely unstained oocysts.\nhttps://www.cdc.gov/dpdx/cryptosporidiosis/\nAmerican Society for Microbiology (ASM), 2016. Endospore Stain Protocol.\nDescribes bacterial endospore staining with carbol fuchsin, including a modification of Dorner\u0026rsquo;s method without a separate acid-decolorization step.\nhttps://asm.org/ASM/media/Protocol-Images/Endospore-Stain-Protocol.pdf?ext=.pdf\nWorld Health Organization, 1998. Laboratory services in tuberculosis control. Part II: Microscopy. WHO/TB/98.258.\nIncludes the recipe for 3% acid-alcohol: 3 mL of concentrated HCl added to 97 mL of 95% ethanol.\nhttps://iris.who.int/bitstream/10665/65942/2/WHO_TB_98.258_%28part2%29.pdf\nWorld Health Organization, 1982. Staining methods for acid-fast bacteria.\nDescribes classical heated Ziehl–Neelsen staining with carbol fuchsin and decolorization using 15% sulfuric acid.\nhttps://iris.who.int/bitstream/handle/10665/260733/PMC2366253.pdf?isAllowed=y\u0026sequence=1\nWorld Health Organization, 1999. Tuberculosis: a manual for medical students. WHO/CDS/TB/99.272.\nDescribes the heated Ziehl–Neelsen method, acid-alcohol decolorization and a formulation using 25% sulfuric acid.\nhttps://iris.who.int/bitstream/handle/10665/68559/WHO_CDS_TB_99.272.pdf\nVilchèze, C., Kremer, L., 2017. Acid-Fast Positive and Acid-Fast Negative Mycobacterium tuberculosis: The Koch Paradox. Microbiology Spectrum, 5(2).\nReviews the history of acid-fast staining from Koch through Neelsen and later modifications, along with ZN-negative forms of M. tuberculosis, changes in the bacterial envelope and the limitations of negative staining results.\nhttps://doi.org/10.1128/microbiolspec.TBTB2-0003-2015\nDella Speranza, V., Fail, R., 2000.\nPhenol Myth Unveiled! Were Ziehl-Neelsen and Kinyoun Mistaken?\nHistoLogic, 33(2), 21–23. Study of mycobacteria stained with an aqueous basic fuchsin solution without phenol.\nhttps://sakura-merged.planeteria-development.com/getattachment/f46887f6-b611-4878-8ed0-1de6e1eb0987/434\nMcCollough, C.B., 2008.\nApplication of an aqueous acid-fast staining technique\nto detect pathogens of aquatic species.\nBiotechnic \u0026amp; Histochemistry, 83(3–4), 191–197. Application of phenol-free aqueous fuchsin to detect mycobacteria and other pathogens of fish and aquatic invertebrates.\nhttps://doi.org/10.1080/10520290802450780\nGomes, A., Amaral, P., Santos, R., Santos, S.,\nTortosa, F., Mendonça, P., Marques-Ramos, A., 2020.\nGASMoC method: a phenol-free technique\nto detect acid-fast bacilli.\nHistochemistry and Cell Biology, 153, 63–69. Comparison of classical Ziehl–Neelsen staining with a phenol-free modification, including a control using zebrafish tissue containing Mycobacterium marinum.\nhttps://doi.org/10.1007/s00418-019-01825-0\nCaulfield, A.J., Wengenack, N.L., 2016. Diagnosis of active tuberculosis disease: From microscopy to molecular techniques. Journal of Clinical Tuberculosis and Other Mycobacterial Diseases, 4, 33–43. Reviews acid-fast staining, the hydrophobic mycobacterial cell wall, mycolic acids and dye-complex resistance to decolorization.\nhttps://pmc.ncbi.nlm.nih.gov/articles/PMC6850262/\nWorld Health Organization, 1982. General tests / staining procedure for acid-fast bacilli.\nNotes that high lipid content makes dye penetration difficult; staining may involve prolonged exposure to carbol fuchsin or heating.\nhttps://iris.who.int/bitstream/10665/62463/1/BLG_UNDP_82.1_eng.pdf\nRamos, A. et al., 2019. GASMoC method: a phenol-free technique to detect acid-fast bacilli.\nExample of a study of a modified phenol-free technique for detecting acid-fast bacteria.\nhttps://pubmed.ncbi.nlm.nih.gov/31654127/\nWorld Health Organization, n.d. Ziehl–Neelsen procedure: fundamentals.\nStates that several acids can be used for decolorization, including hydrochloric, sulfuric and nitric acid, and describes the role of acid treatment in regressive differentiation.\nhttps://applications.emro.who.int/docs/EM_SND_MTG_STR_LEP_CNT_9_3_EN.pdf\n","permalink":"https://fossamethod.ru/en/posts/index_metod/","summary":"When some reagents are unavailable, the investigation is not necessarily useless. The key is to understand what each step does, what information it provides, and which conclusions can no longer be drawn if that step is omitted.","title":"Tradition Instead of Science I. Method"},{"content":" Depth of analysis F. F.O. F.O.S. FMC: treatment or ritual? FMC is one of those mixtures that has become so firmly established in aquarium practice that simply using it is sometimes regarded as sufficient action.\nThe fish is rubbing — FMC.\nMucus appeared — FMC.\nParasites are suspected — FMC.\nIt is not quite clear what is happening — FMC again.\nThe problem is not the mixture itself. Formalin, malachite green, and methylene blue do have biological activity and can be useful in certain situations\rTwo Sides of One Dosage\rAquarium medications: remedy or threat? Pros and cons of antibiotics, formalin, methylene blue, malachite green, and the FMC mixture.\r. The problem begins when FMC ceases to be a means of acting against particular groups of pathogens and turns into a universal procedure: \u0026ldquo;give the fish a bath\u0026rdquo;.\nWhere did FMC come from in the first place? FMC did not originate as a ten-minute \u0026ldquo;bath for everything\u0026rdquo;. Gerald Bassleer\u0026rsquo;s handbook states that the precursor of the mixture was the Leteux–Meyer Mix, proposed in 1972: 3.3 g of malachite green per 1 L of formalin (Leteux \u0026amp; Meyer, 1972). In 1979, G. Bassleer proposed a stock solution containing three components (Bassleer, 2010):\n3.5 g malachite green; 3.5 g methylene blue; 1 L formalin. The recommended dosage is 1 ml per 100 L of water, with a single treatment intended to provide approximately two days of exposure. For ichthyophthiriosis, a water change followed by repeated treatment after two days was recommended (Bassleer, 2010). In other words, the original logic of FMC use was not a few minutes of contact with a concentrated mixture, but prolonged exposure to a comparatively low concentration of the preparation in water.\nFor comparison, the same handbook gives two fundamentally different treatment regimens for formalin alone (Bassleer, 2010):\n1–2 ml per 100 L of water for 12–48 hours; 0.125–0.25 ml per 1 L of water for 30–60 minutes. So even for the same substance, the treatment regimen is determined not only by the name of the drug, but by the combination of concentration and exposure time. This is an important point.\nIt is not enough simply to say: \u0026ldquo;Formalin is used against ectoparasites\u0026rdquo;.\nThe same formalin can be used as a prolonged treatment at a relatively low concentration or as a short bath at a much higher concentration. These are already different exposure regimens.\nThis is exactly why the phrase \u0026ldquo;Let\u0026rsquo;s bathe the fish in FMC for 10 minutes\u0026rdquo; tells us almost nothing by itself about whether the treatment is rational.\nWe need to know:\nthe concentration of the mixture; the duration of exposure; the suspected pathogen; the sensitivity of the fish; the water conditions; and, most importantly, where this particular regimen came from in the first place. If a source specifies tens of minutes or tens of hours for formalin, but multi-day exposure for FMC, then a ten-minute FMC bath requires its own justification.\nThe name of a drug does not determine the treatment regimen. The regimen is determined by dose, time, and purpose.\nThe fact that a fish was bathed does not mean anything was treated The phrase \u0026ldquo;the fish was bathed in FMC\u0026rdquo; describes a procedure, but says almost nothing about treatment. To evaluate the result, we need to know at least:\nwhat was suspected what was found before treatment what concentration was used how long the exposure lasted what water the bath was performed in what changed afterward whether the suspected pathogen remained Without this information, FMC easily turns into action for the sake of action. We see that the fish was placed in a colored solution for ten minutes, and psychologically it creates the impression that treatment has been performed. But treatment is defined not by the fact of contact with a drug, but by whether the biological objective was achieved.\n\u0026ldquo;If it got better, then it worked\u0026rdquo; Not necessarily.\nAfter a bath, a fish may look better for several reasons:\nthe amount of surface mucus decreased; some ectoparasites actually died or detached; the irritating load on the skin changed; the fish was transferred into cleaner water; for some time, the fish had less contact with the source of reinfection. None of these possibilities by itself proves which component of the mixture had an effect or that the cause of the disease was eliminated. And an improvement in appearance certainly does not always mean that the pathogen has been destroyed.\nYou can test your reasoning here: https://fossamethod.ru/ru/test/reasoning-test/\nResponse to treatment is an observation. A diagnosis is already an interpretation of that observation.\nThey are not the same thing.\nWhat if the parasite really is sensitive to FMC? Then using the mixture may be entirely justified. But even here, questions remain.\nAt which stage of its life cycle is the parasite sensitive?\nIs it on the surface or deeper in the epithelium?\nIs the exposure time sufficient?\nCould the therapeutic concentration also be too stressful for an already weakened fish? A short bath prescribed simply because \u0026ldquo;we usually use FMC\u0026rdquo; looks particularly questionable. If the exposure is insufficient for the treatment target, but sufficient to irritate the gills and skin, we get the worst of both worlds:\nthe parasite survived the treatment, while the fish received an additional burden.\nThis is no longer a question of whether FMC is a good drug or a bad one. It is a question of whether the method matches the task.\nWhy a mixture is convenient — and therefore dangerous A mixture of several active components is psychologically perceived as more reliable:\n\u0026ldquo;If one component does not work, another one will\u0026rdquo;.\nBut the same principle works in the opposite direction. Each component has its own toxicity, its own spectrum of activity, and its own limitations. Therefore, adding a second and third substance not only broadens the potential action of the mixture, but also increases the number of factors that must be taken into account.\nThe more complex the mixture, the less sense it makes to use it without understanding the cause of the disease.\nThe most inconvenient situation Imagine this: a fish shows nonspecific behavior, for example rubbing against objects. It is bathed in FMC. A day later, the behavior decreases. What has been demonstrated? Practically nothing. We do not know:\nwhether there was a parasite at all; which parasite it was; whether it was on the skin or gills; whether the mixture affected it; which component of the mixture was significant; whether the behavior disappeared for some other reason. And yet this is exactly how traditions are born:\n\u0026ldquo;FMC helps when the fish is scratching\u0026rdquo;. After some time, the original observation turns into a treatment rule.\nWhere are the \u0026ldquo;traditions instead of science\u0026rdquo; here? Not in the fact that FMC is an old preparation. And not in the idea that it cannot be used. The problem begins when the name of the mixture replaces the definition of the task. \u0026ldquo;Do FMC\u0026rdquo; becomes a goal in itself. Although the correct order is the reverse:\ndetermine what we are observing; formulate a working hypothesis; understand what target we want to act upon; choose the drug and exposure regimen; check the result. If the first three steps are missing, treatment easily turns into a ritual.\nA drug does not become scientifically justified simply because it has been used for many years.\nBut an old drug does not become bad simply because it is old.\nThere is always one question: why exactly are we using it here and now?\nLiterature Bassleer, G., 2010. Новый иллюстрированный справочник болезней рыб для декоративных тропических и прудовых рыб: наблюдение, диагностика, профилактика, лечение. Пер. Н. О. Лисова. М.: Учебный центр \u0026ldquo;Аква Лого\u0026rdquo;. 232 с. ISBN 978-5-9902638-1-9.\nMain source for the FMC formulation cited above, the note that G. Bassleer developed the stock solution in 1979, the dosage of 1 ml/100 L, and the formalin treatment regimens.\nhttps://www.researchgate.net/publication/327941229_New_illustrated_guide_to_fish_diseases\nLeteux, F., Meyer, F.P., 1972. Mixtures of malachite green and formalin for controlling Ichthyophthirius and other protozoan parasites of fish. The Progressive Fish-Culturist, 34(1), 21–26.\nClassic paper on the malachite green–formalin mixture for treatment of ichthyophthiriosis and other protozoan infections; in later literature, this combination is often referred to as the Leteux–Meyer mixture.\nhttps://doi.org/10.1577/1548-8640(1972)34%5B21:MOMGAF%5D2.0.CO;2\n","permalink":"https://fossamethod.ru/en/posts/index_desease/","summary":"FMC can be useful, but simply bathing the fish proves very little. We examine the origins of the mixture, formalin and FMC regimens, the relationship between dose and exposure time, and how treatment becomes ritual when the drug replaces the clinical question.","title":"Traditions Instead of Science. II"},{"content":" Depth of analysis F. F.O. F.O.S. \u0026ldquo;The fish is scratching\u0026rdquo; A fish rubbing against rocks, substrate, or the bottom is, by itself, an objectively observable behavior. In the literature this behavior is usually described as flashing or rubbing: the fish suddenly contacts a surface with its side, rolls its body along it, and may repeat the movement several times. Such behavior has indeed been described in ectoparasitic infections and other lesions of the skin and gills (Garcia et al., 2014) (Maddocks et al., 2016). At this level, everything is simple: we see an action. The problem begins afterward — when a cause is automatically assigned to that action.\n\u0026ldquo;The fish is scratching.\u0026rdquo;\nThen:\n\u0026ldquo;Probably its gills.\u0026rdquo;\nAnd then:\n\u0026ldquo;So it must be parasites.\u0026rdquo;\nBut how well can we actually determine the cause of such behavior from observation alone?\nImagine a simple experiment The examiner already knows the true cause of the behavior. There are two groups. In the first, the fish have pronounced skin irritation caused by sharply unsuitable pH. In the second, there are large numbers of monogeneans on the gills. In both groups, the fish rub against the substrate and decorations. The pH example is not hypothetical: chemonociceptive receptors responding to low pH and other chemical irritants have been demonstrated in rainbow trout (Mettam et al., 2012). And with monogeneans, flashing is indeed described as a clinical sign (Garcia et al., 2014). The observer is shown only the behavior and asked:\n\u0026ldquo;In which case is the skin irritated, and in which case are the gills irritated?\u0026rdquo;\nAnd here an uncomfortable question appears:\n\u0026ldquo;How much better would the rate of correct answers be than random guessing?\u0026rdquo;\nIf it were significantly better, then there must be specific behavioral features by which one cause can genuinely be distinguished from the other. Those features could then be described, tested, and used. But if we cannot name such features, then the statement:\n\u0026ldquo;It is scratching its gills\u0026rdquo;\nis not an observation, but an interpretation.\nWhat features are we actually using? Can you confidently determine what exactly is causing the rubbing without a scraping, necropsy, or microscopy?\nCan you describe:\n\u0026ldquo;how rubbing caused by skin irritation differs from an attempt to scratch the gills?\u0026rdquo;\nWhich part of the body touches the surface first? How does the trajectory of the movement change? Is there a characteristic turn of the head? Does the frequency differ? Is the movement linked to respiration? Is there a specific sequence of actions? If such differences exist, they can be studied.\nIf the answer is reduced to:\n\u0026ldquo;You can just tell by looking at the fish,\u0026rdquo; then this is no longer a diagnostic criterion\u0026hellip;it is the observer\u0026rsquo;s impression.\nAnd an even more uncomfortable question Are we even sure that a fish can scratch the gills themselves? The gills are located beneath the operculum or inside the branchial cavity and do not directly contact the substrate or a rock. During external rubbing, the fish can mechanically affect the head region, the skin, the operculum, and the margins of the gill opening. But the movement itself does not show that the fish is acting specifically on the gill lamellae. Gill irritation may indeed trigger such a motor response. This is entirely plausible and consistent with descriptions of severe monogenean gill infestations, in which flashing is observed together with respiratory disturbances (Garcia et al., 2014). But the literature usually records the presence of this behavior as a clinical sign rather than describing a specific kinematic pattern that would allow one to say confidently from the movement alone: \u0026ldquo;the fish is scratching its gills.\u0026rdquo;\nBut that is already a different statement:\n\u0026ldquo;Gill irritation can cause flashing.\u0026rdquo;\nIt is not the same as:\n\u0026ldquo;The fish is scratching its gills.\u0026rdquo;\nThe first describes an association between irritation and behavior. The second assumes a specific purpose of the movement. And that purpose is precisely what we do not know.\nWhere does observation end? One can say:\n\u0026ldquo;The fish repeatedly makes abrupt lateral contact with the substrate.\u0026rdquo;\nOne can say:\n\u0026ldquo;This behavior is often described as flashing and associated with irritation of the skin or gills\u0026rdquo; (Garcia et al., 2014) (Maddocks et al., 2016).\nBut the phrases:\n\u0026ldquo;It is itchy.\u0026rdquo; \u0026ldquo;It is scratching its gills.\u0026rdquo; \u0026ldquo;It is monogeneans.\u0026rdquo;\n— already belong to different levels of interpretation.\nAnd each subsequent level requires additional evidence.\nWe observe behavior. The cause of that behavior still has to be demonstrated.\nReferences Garcia, R.L., Hansen, A.G., Chan, M.M., Sanders, G.E., 2014. Gyrodactylid Ectoparasites in a Population of Rainbow Trout (Oncorhynchus mykiss). Journal of the American Association for Laboratory Animal Science, 53(1), 92–97.\nA clinical case of gyrodactylid infestation in rainbow trout. The authors describe erratic swimming and flashing; they also note that gyrodactylids affect the superficial layers of the skin and gills and can cause irritation, epithelial hyperplasia, mucus hypersecretion, and pruritus, which is inferred from flashing.\nhttps://pmc.ncbi.nlm.nih.gov/articles/PMC3894654/\nMettam, J.J., McCrohan, C.R., Sneddon, L.U., 2012. Characterisation of chemosensory trigeminal receptors in the rainbow trout, Oncorhynchus mykiss: responses to chemical irritants and carbon dioxide. Journal of Experimental Biology, 215(4), 685–693. https://doi.org/10.1242/jeb.060350\nAn experimental study of chemically sensitive receptors in rainbow trout. Responses to potentially damaging chemical stimuli, including low pH, acetic acid, and citric acid, were demonstrated. This confirms the physiological possibility of pronounced skin irritation without the involvement of parasites.\nhttps://pubmed.ncbi.nlm.nih.gov/22279076/\nMaddocks, C.E. et al., 2016. Puffy Skin Disease Is an Emerging Transmissible Condition in Rainbow Trout Oncorhynchus mykiss Walbaum. PLOS ONE, 11(7), e0158151.\nIn an experiment involving a disease with pronounced skin lesions in trout, flashing was observed: the fish moved down toward the bottom, rubbed their sides against the surface, and rapidly righted themselves. This is a good example of similar behavior arising from skin pathology and not, by itself, indicating a gill localization.\nhttps://pmc.ncbi.nlm.nih.gov/articles/PMC4938586/\n","permalink":"https://fossamethod.ru/en/posts/index_fish_scrab/","summary":"Flashing is observable behavior, while “itching,” “gill irritation,” and “parasites” are already explanations. We examine what can actually be observed, which conclusions genuinely follow from the fish’s behavior, and where a familiar phrase turns into an unproven causal model.","title":"Traditions Instead of Science. III"},{"content":"\nDepth of analysis F. F.O. F.O.S. “Granulomas? Then it must be fish tuberculosis” When granulomas are found in the parenchymal organs of a fish, the next thought often comes almost automatically:\nMycobacteriosis.\nOr, more simply:\nFish tuberculosis.\nThe association is understandable. Granulomas are indeed very common in fish with mycobacteriosis. The problem begins when a characteristic response of the organism is treated as the name of the causative agent. First, we need to establish what we actually saw.\nWhat is a granuloma? Typical granulomas associated with mycobacteriosis. One classical definition of a granuloma is a compact, organized collection of mature mononuclear phagocytes, primarily macrophages (large immune cells that engulf bacteria, viruses, and cellular debris).\nNecrosis (irreversible cell death), giant cells (very large, usually multinucleated cells), lymphocytes (a type of immune cell), and other familiar components of granulomas may be present, but none is essential to the definition. What matters is the organized accumulation of mature macrophages (Pagán \u0026amp; Ramakrishnan, 2018). A simpler way to express the modern definition is:\nA granuloma is an organized attempt by macrophages to deal with something that a single macrophage could not handle.\nPagán and Ramakrishnan offer a particularly clear model:\nIf the first phagocyte engulfs an object and manages to destroy it, there is no need for a granuloma.\nIf the object persists, is difficult to break down, or is too large, additional cells are recruited and a more organized structure forms (Pagán \u0026amp; Ramakrishnan, 2018).\nIn other words, the very appearance of a granuloma tells us primarily that:\nsomething was persistent enough that an ordinary phagocytic response (an immune defense in which cells called phagocytes, such as macrophages, recognize, engulf, and digest foreign particles, bacteria, and dead cells) was insufficient.\nIt does not even have to be “foreign” As early as 1925, Margaret Reed Lewis observed the behavior of monocytes in culture. These cells responded not only to tuberculosis bacteria or experimentally introduced coal particles.\nThey also engulfed:\nthe body\u0026rsquo;s own melanin granules (small intracellular compartments, or organelles, that contain the natural dark pigment melanin); dead granulocytes (a type of white blood cell containing prominent granules with biologically active substances involved in immune defense and inflammation); erythrocytes (red blood cells that transport oxygen from the respiratory organs to the tissues and carry carbon dioxide back). During cultivation, monocytes developed into macrophages (large immune cells that engulf bacteria, viruses, and cellular debris). After several days, cells that had engulfed difficult-to-remove material acquired an epithelioid appearance, and some fused to form multinucleated giant cells (Pagán \u0026amp; Ramakrishnan, 2018).\nThus, the distinction between “self” and “foreign” is not the only thing that matters in the development of a granulomatous response.\nAnother question is more important:\nCan the material be removed quickly, or not?\nA dead cell does not literally become a “foreign body.” It remains material belonging to the organism. But when a cell breaks down, it leaves behind membranes (thin, flexible layers of lipids and proteins that enclosed the cell and its internal organelles, separating them from the surroundings), lipids (a broad group of fats and fat-like organic substances that are insoluble in water but soluble in organic solvents), proteins (complex organic molecules made of amino-acid chains that serve as structural components and carry out many biological functions), and other cellular debris (the remains of destroyed cells and tissues after cell death, inflammation, or injury). This material has to be cleared away. If it persists in the tissues, phagocytes (including macrophages, monocytes, and neutrophils) continue to respond, attempting to engulf and remove the remnants of destroyed cells. Such a response can become prolonged and contribute to chronic granulomatous inflammation.\nThat is why the equation:\n“granuloma = infectious agent”\nis too simplistic from the outset.\nA mechanism older than fish The granulomatous response appears to be much older than one might expect of the complex cellular immune system of vertebrates. Granulomas are formed not only by mammals, birds, and fish. They have also been described in mollusks, worms, and insects (Pagán \u0026amp; Ramakrishnan, 2018). One example is particularly striking. A parasitoid wasp lays an egg in a fruit-fly larva. The egg is too large for an individual phagocyte to engulf. Instead, cells surround it and form an organized granuloma-like structure. The underlying task remains the same:\nIf you cannot destroy it, isolate it.\nIn the freshwater clam Corbicula fluminea, a granulomatous response can even develop around the animal\u0026rsquo;s own larvae when, for some reason, they are not released normally. Their remnants are subsequently resorbed (Pagán \u0026amp; Ramakrishnan, 2018). It is hard to imagine a clearer example of why the presence of a granuloma alone tells us nothing specific about mycobacteria.\nMany different causes A granulomatous response may be triggered by very different agents. In their review, Pagán and Ramakrishnan list bacteria, fungi, protozoa, helminths, and viruses among the infectious causes. Granulomas may also arise around foreign material and in a variety of noninfectious inflammatory conditions (Pagán \u0026amp; Ramakrishnan, 2018).\nSo this line of reasoning:\ngranuloma → mycobacterium\ndoes not work.\nA better formulation is:\ngranuloma → a persistent factor → determine what that factor is.\nIn aquarium practice, mycobacteriosis is indeed among the first possibilities to investigate when multiple granulomas are present. But the leading differential diagnosis is not yet an established diagnosis.\nMycobacteria The story becomes even more interesting with mycobacteria. For a long time, a granuloma was imagined almost as a fortress built by the organism around a bacterium:\nHere are the bacteria; here is a wall of immune cells around them; the infection has been contained.\nThis mechanism does exist. But it turned out to be only part of the picture. Studies of Mycobacterium marinum in zebrafish have shown that pathogenic mycobacteria can exploit the very process of granuloma formation:\nAn infected macrophage attracts new macrophages. It dies. Another macrophage engulfs its remains, together with the bacteria inside. Now the next macrophage is infected. It, too, becomes part of the granuloma. In these experiments, the number of infected macrophages began to rise sharply after cellular aggregates formed. At the same time, the number of viable mycobacteria increased (Pagán \u0026amp; Ramakrishnan, 2015).\nThe result is almost paradoxical:\nthe organism recruits cells to contain the infection, while the bacterium uses the arriving cells as new sites for replication.\nNor is a mature granuloma necessarily a sealed capsule. Cells continue to enter and leave it, and infected macrophages can move away from the primary focus and contribute to the formation of new lesions (Pagán \u0026amp; Ramakrishnan, 2015).\nThat makes the modern view of granulomas far more interesting than the old one:\nA granuloma can both contain an infection and help the pathogen spread.\nWhich process predominates depends on the stage of infection, the state of the immune response, and the properties of the pathogen itself.\nMany granulomas — many bacteria? Not necessarily.\nA granuloma reflects more than the number of pathogens present. It reflects how the organism interacts with them. When the cellular response is effectively organized, well-defined granulomas may develop. When macrophage function is impaired, lesions may become disorganized and necrotic even while the bacterial burden is very high. In experimental models where tumor necrosis factor (TNF)—a signaling protein through which immune cells regulate inflammation and defense against infection—was disrupted, mycobacteria proliferated actively while granulomas lost their organized structure (Pagán \u0026amp; Ramakrishnan, 2015).\nThus, “generalized mycobacteriosis, but very few well-formed granulomas” is not a contradiction at all. Sometimes it may indicate the opposite of what one would expect: the immune system is failing to contain the infection effectively.\nWhat if we use Ziehl–Neelsen staining? This is where we move from a suspicion to the next level of evidence.\nIf numerous rod-shaped bacteria are found within granulomas and retain carbol fuchsin after acid decolorization, the hypothesis of mycobacteriosis becomes considerably stronger. But here, too, we must avoid skipping another step. Ziehl–Neelsen staining demonstrates acid-fastness. It does not automatically establish the species of bacterium.\nMore on this: Traditions Instead of Science I. Method: Staining and the Limits of Interpretation\nSpecies-level identification requires other methods, such as culture, PCR, sequencing, or a combination of these approaches.\nA granuloma tells us:\nAn organized chronic tissue response is taking place.\nStaining tells us:\nStructures with particular staining properties are present here.\nMolecular or culture-based methods bring us closer to answering:\nWho exactly is present?\nOne does not replace the other.\nSometimes a granuloma has nothing to do with bacteria Here are two fish spleens with numerous whitish lesions. In the first case, mycobacteria were detected by microscopy. In the second, intracellular microorganisms morphologically resembling Histoplasma were found.\nThe first photograph is included specifically for comparison. The two organs show similar changes to the naked eye, but microscopy reveals very different findings. This is precisely why numerous whitish nodules do not, by themselves, identify the cause.\nFish spleen. Multiple small whitish granulomatous lesions. Mycobacteria were detected by microscopy. Fish spleen. Multiple whitish nodules of varying sizes. Microscopy revealed intracellular microorganisms morphologically resembling Histoplasma.\nIt is possible to find numerous granulomatous lesions without detecting acid-fast bacteria in them. The cause may be an entirely different process—for example, a parasitic infection. That is why it is better to describe what is actually visible first:\n“multiple granulomas”\nand only then investigate their etiology.\nBecause the entry:\n“multiple granulomas — mycobacteriosis”\nquietly turns an observation into a diagnosis.\nGranuloma shape matters too Liver of Apteronotus albifrons with granulomatous lesions (acid-fast bacteria detected):\nBrightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off Concretions in the kidney of a neon tetra. Microscopic preparation of a neon tetra kidney. Round and oval structures of different sizes, with well-defined margins and heterogeneous contents, tentatively interpreted as mineral concretions. Some are surrounded by cellular structures resembling a granulomatous reaction. No mycobacteria were detected, and similar structures were not found in other organs.\nBrightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off A granuloma is not merely a “nodule” in tissue. Its organization also matters. The morphology of a lesion often depends on what lies at its center, and how many such centers there are. We can distinguish several patterns schematically.\nFactors influencing granuloma shape A single compact center If the initiating factor is small, the response may organize around one center and produce a relatively round, compact granuloma. A large or irregularly shaped center If the underlying structure is large, uneven, or difficult to remove—such as a parasitic structure, a concretion, or a substantial area of tissue breakdown—the resulting granuloma may follow its contours and become less regular in shape. Two adjacent centers Sometimes two lesions lie close together in the tissue. Their outer zones of response may merge, creating the impression of a single complex granuloma. But two distinct centers suggest two closely spaced granulomas rather than one irregular lesion. Necrotizing and non-necrotizing granulomas Fibrous nodular lesions in the kidneys of a gudgeon (Gobio gobio). The lesions range from 0.5 to 8 mm in size. Their central regions have a homogeneous appearance. No acid-fast bacteria were detected.\nBrightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off Another important feature is whether necrosis is present at the center.\nWhen cells in the center of a granuloma break down and form an amorphous mass, the lesion is termed a necrotizing granuloma.\nCentral necrosis is characteristic of many mycobacterial granulomas, but it also occurs in other diseases. Conversely, mycobacteriosis can occur without necrosis.\nIn some fungal and parasitic diseases, numerous well-organized granulomas without central necrosis may be present even in severe disseminated disease.\nWithin a single epizootic episode, granulomas often have similar structures. When the same agent affects a relatively uniform group of fish, the granulomatous response—its shape, capsule development, and the presence or absence of necrosis—may recur in a fairly consistent pattern. Yet this morphotype (a set of characteristic structural and shape-related features) reflects the interaction between a particular pathogen and a particular host; it is not a universal property of the pathogen.\nWhat surrounds a granuloma? It is important to examine not only the center of a granuloma but also its periphery. In some cases, the boundary with the surrounding tissue is poorly defined. In others, the lesion is surrounded by several layers of macrophages, other inflammatory cells, and connective-tissue elements.\nOver time, a dense connective-tissue capsule may form around a granuloma. Its thickness and prominence depend on the duration of the process, the nature of the irritant, and the tissue response of the host.\nWhere does “tradition instead of science” come into this? Not in the association between granulomas and mycobacteriosis itself. That association is real and can be very useful in practice. The problem arises when a probable cause is treated as the only possible cause simply because we are accustomed to seeing the two together.\nThe shortcut “saw a granuloma → wrote ‘tuberculosis’” saves time.\nBut it discards the most interesting part of diagnosis. What initiated the granuloma? Are bacteria present within it? Are they acid-fast? Is an infectious agent present at all? What is happening in the surrounding tissue? Is the process localized or generalized? Only after asking these questions do we have grounds to move from a morphological feature toward a diagnosis.\nA granuloma is not a diagnosis.\nIt is a trace of the organism\u0026rsquo;s response.\nAnd the task of diagnosis is to find out why that response was needed.\nReferences Pagán, A.J., Ramakrishnan, L., 2018. The Formation and Function of Granulomas. Annual Review of Immunology 36, 639–665.\nhttps://doi.org/10.1146/annurev-immunol-032712-100022\nA review of granuloma formation and function, including the definition of a granuloma, its evolutionary origins, infectious and noninfectious causes, responses to foreign material and persistent endogenous structures, and both the protective and pathological roles of granulomatous inflammation.\nPagán, A.J., Ramakrishnan, L., 2015. Immunity and Immunopathology in the Tuberculous Granuloma. Cold Spring Harbor Perspectives in Medicine 5, a018499.\nhttps://doi.org/10.1101/cshperspect.a018499\nA review of the interaction between mycobacteria and granulomas. Models including Mycobacterium marinum infection in zebrafish demonstrate that granulomas do not merely contain infection: mycobacteria can exploit macrophage recruitment and death to multiply and spread.\n","permalink":"https://fossamethod.ru/en/posts/index_granulomas/","summary":"Granulomas do not necessarily mean mycobacteriosis. Shape, size, necrosis, and capsule development characterize a pathological process but do not identify its cause. Using examples of different lesions in fish, we examine the limits of morphological diagnosis and the danger of turning observations into ready-made diagnoses.","title":"Traditions Instead of Science IV. Diagnosis."},{"content":"\nDepth of analysis F. F.O. F.O.S. “Granulomas Found—So It Must Be Mycobacteriosis” During fish necropsies, whitish nodules in the spleen, liver, or kidneys often raise suspicion of mycobacteriosis. This suspicion is reasonable: granulomatous lesions are indeed characteristic of many cases of mycobacterial infection. The mistake comes at the next step—when a morphological finding is treated as an already established etiology.\nThree concepts need to be kept separate: a visible nodule, a granuloma, and mycobacteriosis. They are related, but they are not equivalent.\nWhat Are We Actually Seeing? Two photographs of fish spleens show numerous whitish lesions. Their gross appearances are similar, but microscopy reveals different findings.\nFish spleen with numerous whitish lesions. Mycobacteria were detected by microscopy. Fish spleen with numerous whitish nodules. Other intracellular microorganisms were found in the microscopic preparation. The color and distribution of visible lesions do not reveal their cellular architecture. Therefore, a white nodule seen at necropsy should not automatically be called a granuloma. The tissue must first be examined—for example, by histology.\nWhat Is a Granuloma Made Of, and Why Does It Form? In its classical definition, a granuloma is an organized collection of mature mononuclear phagocytes, primarily macrophages. These cells engulf and process microorganisms, foreign particles, and debris from damaged tissues. Other cells may be present in a granuloma, and its center may contain necrosis, but neither feature is required by the definition (Pagán \u0026amp; Ramakrishnan, 2018).\nIf a macrophage can eliminate an irritant, a prolonged organized reaction may not develop. But when material persists, is difficult to break down, or is too large, additional cells are recruited and a localized lesion forms.\nImportantly, the persistent material does not necessarily come from outside the body. The reaction may also develop around remnants of the organism\u0026rsquo;s own damaged tissues. Thus, the equation “granuloma = infection” is incorrect even at the level of mechanism.\nGranulomas can develop in response to various bacterial, fungal, and parasitic infections, as well as certain noninfectious processes. A granulomatous response describes the host\u0026rsquo;s reaction; its etiology must be established separately.\nWhy Shape and Necrosis Do Not Provide a Diagnosis When examining granulomatous lesions, we assess their organization, size, number, the presence of necrosis, the prominence of peripheral cellular layers, and the development of a connective-tissue capsule.\nThe full article presents a useful diagram with a single compact center, a large irregular center, and adjacent lesions that may merge. This is a model of possible patterns of organization, not a way to identify a pathogen reliably from a lesion\u0026rsquo;s outline.\nSchematic illustration of factors that may influence the appearance of granulomatous lesions. Necrosis—the death of cells within a lesion—does occur in mycobacteriosis, but it is not unique to it. Conversely, the absence of necrosis does not rule out mycobacterial infection. The same applies to capsule thickness and the regularity of lesion contours.\nWithin a group of fish, similar lesions may develop a similar structure. This can help compare cases and suggest a shared pathological process, but it does not make any particular granuloma shape unique to a specific pathogen.\nNot Every Round Structure Is a Granuloma The full article shows structures in neon tetra kidneys that are tentatively interpreted as mineral concretions; some are surrounded by features resembling a granulomatous response. Fibrous nodular structures in gudgeon kidneys are also shown. These findings are deliberately described with caution: without further confirmation, not every nodule or granuloma-like cellular arrangement should be assigned to a specific pathological process.\nView these specimens in the interactive microscope in the F.O.S. article.\nMany Granulomas—Does That Mean a High Bacterial Load? Not necessarily. The number and integrity of granulomas depend not only on the pathogen, but also on how the immune response is organized. Well-formed lesions may help contain infection. When this organization breaks down, mycobacteria may multiply extensively while the granulomas deteriorate.\nMoreover, experimental models of Mycobacterium marinum infection in zebrafish have shown that, under certain conditions, mycobacteria can exploit the recruitment and movement of macrophages to spread further (Pagán \u0026amp; Ramakrishnan, 2015).\nA granuloma, then, is not always a static capsule surrounding a pathogen, nor is it a “counter” of bacterial cells.\nFrom a Finding to an Etiological Diagnosis It helps to distinguish different levels of evidence.\nGross examination. Whitish nodules or lesions are visible in particular organs. This describes their external appearance, not their cellular composition. Tissue microscopy. We assess whether granulomatous architecture is confirmed, what occupies the center of a lesion, and whether necrosis or other changes are present. Special staining. Ziehl–Neelsen staining can reveal structures that retain the dye after acid decolorization. Finding such structures, especially within lesions, strengthens the suspicion of mycobacteriosis. However, acid-fastness does not identify a bacterial species, and a negative stain alone does not rule out infection. Pathogen identification. When necessary, culture, PCR, sequencing, or a combination of methods may be used, taking sample quality and the clinical context into account. For more on what this staining method actually tests, see “Tradition Instead of Science I. Method”.\nThis sequence does not imply that every test is available in every case. Its purpose is to make clear the level of certainty reached by our conclusion.\nWhere Is the Boundary? “Multiple whitish lesions were found in the organs” is a gross observation.\n“Granulomas were confirmed in the tissue” is a morphological conclusion.\n“Acid-fast rod-shaped bacteria were detected” is the result of a special investigation.\n“Mycobacteriosis was diagnosed” is an etiological diagnosis that requires consideration of the evidence as a whole.\nWe should move from one statement to the next as evidence becomes available—not merely because these findings often occur together.\nA granuloma helps characterize a pathological process. Its appearance alone, however, cannot establish the cause.\nReferences Pagán, A. J., Ramakrishnan, L. (2018). The Formation and Function of Granulomas. Annual Review of Immunology, 36, 639–665. https://doi.org/10.1146/annurev-immunol-032712-100022 Pagán, A. J., Ramakrishnan, L. (2015). Immunity and Immunopathology in the Tuberculous Granuloma. Cold Spring Harbor Perspectives in Medicine, 5, a018499. https://doi.org/10.1101/cshperspect.a018499 Other versions: F. — the story of two spleens, without technical terminology · F.O.S. — the full analysis, examples, and interactive microscopy collections.\n","permalink":"https://fossamethod.ru/en/fo/index_granulomas/","summary":"A visible nodule is not necessarily a granuloma, and a granuloma does not necessarily mean mycobacteriosis. We explain the mechanism, morphological features, and steps involved in verifying a diagnosis.","title":"Granulomas in Fish: What Their Structure Reveals—and What It Cannot Prove"},{"content":"\nDepth of analysis F. F.O. F.O.S. If We Change the Staining Method, What Remains of the Result? In diagnostics, it is tempting to see a protocol as a fixed sequence of mandatory steps. If one reagent is missing, the method cannot be performed—and the specimen supposedly has nothing more to tell us.\nBut this confuses two different questions: Can we perform the standard test? and Can we still obtain useful observations from the specimen? The answers are not always the same.\nZiehl–Neelsen staining, used to detect acid-fast bacteria, including mycobacteria, is a good example. Conventional versions use carbol fuchsin, heating, acid or acid-alcohol decolorization, and a counterstain. Each step has its own function.\nIf we change a step, we need to understand what information we have preserved and what we have lost.\nWhat Happens During Staining? Loeffler\u0026#39;s methylene blue stain Ziehl–Neelsen stain Mycobacteria are not detected by routine staining.\nFuchsin stains structures in a specimen. In the conventional method, phenol and heat help the dye penetrate structures, including bacteria that are difficult to stain by ordinary methods.\nThen comes a fundamentally different step: acid treatment. It removes the dye from some structures, while others continue to retain it under the specified conditions. This is how we demonstrate acid-fastness—the ability to retain a stain after a particular decolorization procedure.\nA counterstain helps distinguish tissues and the background.\nSo omitting phenol and omitting acid are not equivalent changes. In the first case, we alter the conditions of primary staining. In the second, we remove the actual test for acid-fastness.\nHeating: 40 °C, 60 °C, or All the Way to Boiling? In the conventional Ziehl–Neelsen method, carbol fuchsin is heated after it has been applied to the specimen, usually until vapors begin to appear. Some protocols associate this visual cue with approximately 60 °C. The dye is kept heated for several minutes (often 3–5 minutes), without allowing it to boil or dry out (\rASM protocol; comparative study).\nBut the appearance of vapors is not the same as boiling: liquids evaporate at temperatures below their boiling points. Thus, “until vapors appear” is only an approximate guide, not a precise way to control temperature. For a reproducible modified procedure, it is better to record the measured dye temperature, exposure time, and concentration.\nWhy not heat it further? Boiling is not the goal of the method. It increases evaporation and can cause the dye to dry out or splatter. With phenol, chemical safety is an additional concern. It is also important to distinguish heat fixation of the specimen before staining from heating the dye during staining—these are separate operations.\nPhenol-free methods use different conditions. Some studies used 0.5% aqueous fuchsin at 60 °C for 15 minutes; the GASMoC method used 1% aqueous fuchsin at 37 °C for 15 minutes. Staining at 37–40 °C is therefore possible in principle, but 40 °C is not a universally validated temperature: any protocol has to be evaluated in terms of dye concentration, exposure time, and specimen type. These findings apply to specific studies; they do not establish that all the conditions are interchangeable.\nCan We Do Without Phenol? Yes, under certain conditions. This is supported by published research, not just isolated observations.\nDella Speranza and Fail (2000) showed that a 0.5% aqueous solution of basic fuchsin, without phenol, could stain mycobacteria at 60 °C in 15 minutes. At room temperature, the same approach performed considerably worse under their conditions. So the outcome depends not only on the composition of the stain, but also on how it is applied (\r2000 study).\nMcCollough (2008) used staining with 0.5% aqueous fuchsin at 60 °C for 15 minutes to examine pathogens of aquatic animals, including Mycobacterium marinum in the kidney of a goldfish (\rstudy).\nGomes et al. (2020) compared conventional staining with a modified phenol-free procedure using 1% aqueous fuchsin at 37 °C for 15 minutes, both on clinical samples and on zebrafish tissue containing M. marinum. In the samples studied, the new procedure was not inferior to the conventional method for detecting acid-fast bacteria. However, the sample size was small, and the findings cannot simply be generalized to all specimens and conditions (\rGASMoC study).\nOne point matters in all these cases: acid decolorization was retained. The researchers changed the primary stain, but they did not abandon the test for the property they were investigating.\nTherefore, the absence of phenol does not, by itself, make it impossible to detect acid-fast bacteria. But the conditions of a particular staining procedure must be evaluated, and its results need appropriate controls.\nWhat Happens If We Leave Out the Acid? Suppose that, after intensive fuchsin staining, red rod-shaped bacteria are visible in the tissue. We can examine their shape, approximate numbers, distribution, and association with altered regions of the organ.\nBut if acid decolorization was not performed, acid-fastness was not tested. We cannot report “acid-fast bacteria detected,” however convincing the rods may look.\nThere is another side to this change. Acid can remove stain not only from the background but also from structures we might want to examine. Without acid, the microscopic field may look more cluttered, but additional objects may remain visible. This can be useful during exploratory examination, although it reduces the selectivity of the procedure.\nTherefore, staining without acid decolorization is not a simplified Ziehl–Neelsen test. It is a different procedure with a different set of permissible conclusions.\nOne Organ, Three Methods For my own comparison, I used specimens prepared from the same angelfish spleen, which contained numerous pale lesions. The specimens were stained in three ways:\nWith phenol, followed by acid decolorization. Without phenol, but with decolorization using 5% sulfuric acid. Without phenol and without acid decolorization. All specimens were imaged using the same microscope and camera.\nRod-shaped bacteria stained with phenol and acid decolorization. Rod-shaped bacteria stained without phenol, with acid decolorization. Rod-shaped bacteria stained without phenol or acid decolorization. Similar red rod-shaped bacteria were observed in all three preparations. This is consistent with the possibility of staining without phenol, including retention of the stain after acid treatment.\nHowever, specimens from a single organ do not allow us to calculate sensitivity or specificity or demonstrate that the three procedures are equivalent. This is a comparison of observed results, not validation of a new diagnostic method.\nWhat If We Use a Different Acid? Different acids and decolorization conditions have been used in historical and modern acid-fast staining methods. Thus, no single acid is a universal, indispensable component of every variant of the method (\rVilchèze and Kremer, 2017).\nBut this does not mean that any acidic solution provides the same test. The type and concentration of the acid, as well as the duration of treatment, affect which structures lose their stain.\nFor example, a concentrated citric acid solution could be considered an experimental decolorizing agent. Even if the background loses its color while the rods remain red, this is not automatically equivalent to a standard test. Appropriate positive and negative control specimens would be needed for comparison.\nA Negative Staining Result Has Limits, Too There is another reason not to turn a staining result into a definitive diagnosis.\nEven mycobacteria do not always exhibit acid-fastness to the same degree. In Mycobacterium tuberculosis, states have been described in which some cells are poorly detected or not detected at all by conventional staining. This is discussed in the work on the so-called “Koch\u0026rsquo;s paradox” (\rVilchèze and Kremer, 2017).\nFor fish diagnostics, the cautious principle is this: a negative staining result does not, by itself, prove that mycobacteria are absent. But neither can every negative stain of fish tissue be explained by “dormant” mycobacteria. That is only one possible explanation and would require investigation.\nConversely, a positive acid-fast staining result does not automatically establish the genus or species of the bacteria. Additional testing, such as PCR or culture, may be needed for identification.\nHow to Describe the Finding Correctly If heated fuchsin was used without subsequent acid decolorization, the report should describe both the procedure and what was actually observed:\nA modified fuchsin staining procedure with heating, but without acid decolorization, was used. Intensely stained rod-shaped bacteria were observed in the tissue. Their acid-fastness was not assessed.\nIt would be incorrect to state that standard Ziehl–Neelsen staining had been performed and that the presence of acid-fast bacteria had been demonstrated.\nThe key distinction: omitting a step does not invalidate the observations already made, but it changes the limits of the conclusions we can draw. A method is not a magic formula that must be recited word for word; it is a sequence of actions, each of which should answer a specific question.\nFor the history of these modifications, the exact experimental conditions, and a detailed bibliography, see the full F.O.S. version. The F. version tells the same story with almost none of the laboratory details.\n","permalink":"https://fossamethod.ru/en/fo/index_metod/","summary":"The roles of phenol, heat, and acid, illustrated by three staining approaches applied to specimens from an angelfish spleen.","title":"Phenol-Free Staining: What Changes in the Method and the Conclusions"},{"content":"\nDepth of analysis F. F.O. F.O.S. When Red Rods Matter More Than the Name of the Method Loeffler\u0026#39;s methylene blue stain Ziehl–Neelsen stain Mycobacteria are not detected by routine staining.\nImagine examining tissue from a sick fish under a microscope. You can see cells, patches of material, and fragments of tissue. But are there any bacteria among them? It\u0026rsquo;s hard to tell.\nLaboratories use special staining methods for situations like this. A stain makes structures visible that would be difficult to distinguish in an unstained specimen.\nIn this case, we use fuchsin—a dye that stains certain cells and bacteria bright red. It lets us see structures under the microscope that would otherwise be difficult to make out. In the conventional method, phenol is added to the fuchsin. Phenol is a chemical that does not stain anything by itself, but helps the dye penetrate bacterial structures that are difficult to stain. This mixture is called carbol fuchsin. Heating also matters. In conventional Ziehl–Neelsen staining, the dye is gently heated until faint vapors appear—approximately 60 °C. It does not need to boil. Heat helps fuchsin stain bacteria, but that does not mean hotter is always better.\nAfter staining, the specimen is treated with acid. The acid removes the dye from many structures, while certain bacteria remain red. This is how we test for acid-fastness—the ability to retain the stain after acid treatment.\nBut the necessary reagents are not always available. So what should we do—put the specimen aside and accept that we cannot learn anything from it?\nI\u0026rsquo;d rather ask a different question: what can we see if we change the usual staining procedure? And, just as importantly, what can we legitimately conclude from the result?\nOne Angelfish, Three Specimens Let\u0026rsquo;s take the spleen of an angelfish with numerous pale spots. We prepare specimens from this tissue and stain them in three different ways.\nIn the first, we follow the conventional procedure: a stain containing phenol, followed by acid treatment. In the second, we leave out the phenol but keep the acid treatment. In the third, we use neither phenol nor acid decolorization.\nWhy do this? Not to give an old method a new name. We want to see how much each step actually matters.\nThe results are easy to see. All three preparations contain clearly visible small red rods, similar in shape and distribution. We use the same microscope and camera for comparison.\nRed rod-shaped bacteria: staining with phenol and acid decolorization. Red rod-shaped bacteria: staining without phenol, but with acid decolorization. Red rod-shaped bacteria: staining without phenol or acid decolorization. This is not a large scientific study, just a comparison of several specimens from the same organ. These images are not enough to claim that all three methods are equally reliable. But they do demonstrate one useful point: changing the procedure does not necessarily make the result disappear.\nWhy You Cannot Simply Skip the Acid There is an important distinction here.\nSome bacteria remain red even after acid treatment. This property is called acid-fastness. It is what the well-known Ziehl–Neelsen staining method is designed to test.\nIf we did not treat the specimen with acid, we did not perform that test. Even if the rods look exactly like those in another preparation, their color alone does not justify calling them acid-fast.\nBut does that make the rods we can see useless? Not at all. We can still examine their shape, number, distribution, and the areas of tissue in which they appear.\nThe distinction is simple:\nSeeing bacteria is one task. Testing whether they are acid-fast is another. Identifying which bacteria they are is a third.\nOne photograph cannot answer all three questions at once.\nSo What Is the Phenol For? Phenol is part of the conventional staining solution and helps the staining process. But “helps” does not mean “cannot be done without it.”\nResearchers have already shown that, under certain conditions, bacteria can be stained with fuchsin without phenol. Temperature turned out to be particularly important. For example, aqueous fuchsin was successfully used at 60 °C for 15 minutes, including on fish tissues (\rMcCollough, 2008). Another study achieved staining at just 37 °C for the same 15 minutes by changing the dye concentration (\rGomes et al., 2020). Both methods retained the subsequent acid decolorization step.\nSo the question “40 degrees, 60 degrees, or all the way to boiling?” cannot be answered with a single number. The result also depends on the solution\u0026rsquo;s composition and the staining time. 37 °C was tested in a particular protocol; that does not prove every staining procedure will work at 40 °C. And boiling is not necessary at all.\nThe point, then, is not whether phenol is good or bad. The question is what function it serves, and whether that function can be achieved another way.\nWhy This Matters When working in diagnostics, you may lack not only reagents but also time, equipment, or the opportunity to send a sample to a laboratory right away.\nIn that situation, it is easy to fall into one of two extremes. The first: “If I cannot do it exactly by the book, there is no point looking at anything.” The second: “I see red rods, so the diagnosis is confirmed.”\nBoth get in the way of thinking.\nA microscope can provide useful information even when a definitive answer is still out of reach. We just have to avoid claiming more than the evidence shows.\nYou can change a method. But then you need to ask yourself again: “What did I actually test? What did I observe? And what do I still not know?”\nThat is the difference between following instructions and understanding why those instructions exist.\nWant to explore the subject further? Read how the staining works and where the limits of interpretation lie or the full discussion, including the method\u0026rsquo;s history, experiments, and sources.\n","permalink":"https://fossamethod.ru/en/f/index_metod/","summary":"Can a specimen still provide useful information when some reagents are unavailable? A story of one experiment and three staining methods.","title":"Red Rods: Why I Changed the Usual Method"},{"content":"\nDepth of analysis F. F.O. F.O.S. Two Spleens. One Diagnosis? Here are two photographs of fish spleens. Both have numerous whitish spots and nodules. At first glance, they look similar.\nSomeone familiar with fish diseases might suspect mycobacteriosis. Or, out of habit, use an even simpler term: fish tuberculosis.\nThere is a reason for that suspicion. Mycobacterial infections often cause nodular lesions in fish organs. But similar appearances do not necessarily mean the same cause.\nLet\u0026rsquo;s see what was found in these two cases.\nFish spleen with numerous whitish lesions. Mycobacteria were detected by microscopy. Fish spleen with numerous whitish nodules. Other intracellular microorganisms were detected in the microscopic preparation. And there is the surprise: they look alike from the outside, but the microscopic findings are different. Seeing only the white spots, we could not have known in advance what we would find inside.\nSo What Is a Granuloma? Sometimes, a necropsy reveals pale nodules. When the tissue is examined under a microscope, some of these turn out to be organized clusters of immune cells. These are called granulomas.\nOne job of these cells is to engulf and remove things that are causing trouble. They can take up bacteria, the remains of dead cells, and other material. But not everything can be broken down and cleared away quickly.\nWhen the problem persists, immune cells may gather around it and form an organized focus. This is one way a granuloma can develop.\nAn important distinction: not every white nodule seen at necropsy is necessarily a granuloma. To call something a granuloma, we need to examine its structure, not just its color and outward shape.\nWhy a Granuloma Does Not Identify a Single Culprit Imagine finding such a cluster of cells in a tissue. What does it tell us?\nPerhaps the body is trying to contain bacteria. But the cause might also be another microorganism, a parasite, a foreign particle, or material left behind by damaged tissue that the body cannot easily remove.\nIn other words, a granuloma shows how the body is responding to a problem, but it does not tell us what that problem is.\nThink of it as finding a repair crew at work. The workers tell us that something has happened, but without inspecting the site, we cannot know whether the problem is a broken pipe, faulty wiring, or a damaged wall.\nGranulomas have another twist: in certain infections, a cluster of immune cells may not only contain the pathogen but also help it spread. That is why the number and appearance of granulomas cannot be used as a simple count of the bacteria present.\nWhat If We Find Red Rods? One way to investigate suspected mycobacteriosis is to stain a tissue preparation. After treatment with a dye and an acid, some bacteria remain red. This property is called acid-fastness.\nIf rod-shaped bacteria with these staining properties are found in the affected tissue, the suspicion of mycobacteriosis becomes stronger. But their color alone does not tell us which bacterial species they belong to. Further tests may be needed.\nConversely, if acid-fast bacteria are not detected, that does not mean every possible cause of the lesions has been ruled out.\nWe explain the staining procedure and its limitations in “Tradition Instead of Science I: Method”.\nSo What Should We Write in the Report? Start with what has actually been established.\nIf all we can see at necropsy are whitish nodules, we can describe them exactly that way. If microscopy confirms that they are granulomas, we can write: “multiple granulomas.”\nBut a diagnosis of mycobacteriosis requires evidence of its own.\nSimilar shape, white color, necrosis, or a large number of nodules cannot replace an investigation into their cause.\nA granuloma is not a diagnosis. It is a trace of the body\u0026rsquo;s response. The task of diagnosis is to find out what made that response necessary.\nWant to explore the topic further? F.O. — how granulomas form and what morphology can tell us · F.O.S. — a full analysis with microscopic preparations and references.\n","permalink":"https://fossamethod.ru/en/f/index_granulomas/","summary":"Two similar-looking spleens, two different microscopic findings. A story about why white nodules and granulomas are not diagnoses in themselves.","title":"White Spots in Fish Organs: Is It Tuberculosis?"},{"content":"\nDepth of analysis F. F.O. F.O.S. FMC In aquarium fish care, FMC sometimes becomes the answer before the question has even been formulated. A fish rubs against decorations, mucus production increases, a parasitic infection is suspected—and a treatment bath is prescribed.\nThis does not necessarily mean the decision is wrong. FMC does contain biologically active substances. The problem arises when the name of the mixture replaces the rationale for using it, and performing a bath is taken as proof that treatment was effective.\nTo distinguish between these situations, we need to understand what FMC contains, where its treatment regimens came from, and which parameters determine the outcome.\nWhat Is FMC? In the formulation discussed here, FMC combines three components:\nFormalin — an aqueous solution of formaldehyde, used against certain external pathogens of fish. Malachite green — a dye with antiparasitic activity. Methylene blue — another dye with its own biological activity. The mixture may act on several biological targets. However, its components have toxic effects as well as useful biological activity. The argument that “three substances are present, so at least one is bound to work” does not stand up to scrutiny.\nEven when the composition is known, the name FMC alone cannot tell us which regimen will be both safe and effective. We also need to know the concentration, duration of exposure, condition of the fish, characteristics of the suspected pathogen, and water conditions.\nWhere Did the Treatment Regimen Come From? The full F.O.S. article examines the history of the mixture through its sources. An early precursor was a combination of malachite green and formalin described by Leteux and Meyer in 1972 for controlling Ichthyophthirius and other protozoan parasites of fish (\rpublication).\nAccording to Gerald Bassleer (2010), he proposed a three-component FMC formulation in 1979. The stock solution described contained 3.5 g each of malachite green and methylene blue per litre of formalin. The regimen given was 1 mL of stock solution per 100 L of water, with exposure lasting approximately two days; for ichthyophthiriasis, another treatment was to follow a water change.\nThis is a historical account of a specific formulation and regimen, not a universal instruction for treating any fish. Its relevance here is different: it involved prolonged contact with a relatively dilute mixture, not an arbitrarily chosen ten-minute bath.\nFor comparison, the same reference separately described two regimens for formalin alone: 1–2 mL per 100 L for 12–48 hours, and 0.125–0.25 mL per litre for 30–60 minutes.\nWe must not conflate formulations when comparing them: formalin regimens cannot automatically be treated as FMC regimens. Even with a single active substance, changing both the concentration and the duration produces a different exposure regimen.\nWhy Exposure Time Cannot Be Separated from Concentration Exposure time is the period during which the fish remains in contact with the preparation. Concentration tells us how much of the active substance is present in the water. Together, they define the exposure conditions, but they do not in themselves guarantee effectiveness.\nA statement such as “ten minutes in FMC” tells us too little to assess the outcome unless we know:\nthe exact formulation and actual concentration of the solution; the duration of contact and water conditions; which organism or pathological process the treatment is intended to eliminate; how susceptible that target is to the chosen exposure; whether the individual fish can tolerate the procedure; what was observed before and after treatment. The parasite\u0026rsquo;s life-cycle stage also matters. If the susceptible stage is inaccessible to the substance during a short bath, the presence of an active preparation does not mean the target has been reached. Whether the parasite is on the body surface or within tissues also affects its likelihood of coming into contact with the substance.\nTherefore, this argument does not work: “Formalin acts against ectoparasites; FMC contains formalin; therefore, ten minutes in FMC is enough.” The essential link is missing: evidence for that particular regimen against the suspected target.\nA preparation is defined not only by its composition but also by the conditions under which it is used. Treatment is justified when the regimen matches the specific objective.\nWhat Does Improvement After a Bath Mean? Imagine a fish that rubs intensely against objects and produces large amounts of mucus before treatment. The day after a bath, the irritation appears reduced and the fish looks better.\nThat is an observation. But several explanations are possible:\nsome external parasites may have died or become detached; the amount of mucus on the body surface may have decreased; water conditions may have changed when the fish was transferred; contact with a possible source of infection may have been reduced; the fish\u0026rsquo;s behaviour may have changed for reasons unrelated to the preparation. Without an initial diagnostic assessment and a follow-up examination, we cannot determine which explanation applies. Even if the parasite burden has genuinely decreased, this does not prove that the pathogen has been completely eliminated or that the effect will persist.\nA common reasoning error occurs here: “the fish improved after treatment” becomes “the treatment eliminated the cause of the disease.” Evidence is needed to bridge these two statements.\nWhat Should Be Checked Before and After? Before evaluating a treatment bath, it is useful to formulate a working hypothesis—for example, that the fish has an external parasitic infestation. Where feasible, microscopic examination of suitable material can be performed on the living fish, documenting the suspected pathogen, the severity of the lesions, and the fish\u0026rsquo;s clinical condition.\nThe next step is to define not merely a preparation but an objective: to reduce or eliminate a particular parasite burden at an acceptable level of risk to the animal. After treatment, we check whether that objective was achieved, rather than looking only for an improvement in appearance.\nIf there was no initial examination, conclusions about efficacy will be limited. If the suspected pathogen was not assessed before and after treatment, we cannot confidently say it has disappeared.\nThe same applies when a fish rubs against objects. Rubbing is not, by itself, a specific sign of parasitic disease and does not automatically determine either the diagnosis or the treatment regimen.\nWhy a Multicomponent Mixture Requires Extra Care Several active substances can tempt us into thinking: “If one does not work, another will.”\nBut the other side of that reasoning is additional limitations and a potential toxic burden. If the chosen exposure time is too short to affect the parasite but long enough to irritate the fish\u0026rsquo;s skin or gills, the procedure may worsen the fish\u0026rsquo;s condition without solving the original problem.\nThis is not an argument against FMC itself. The mixture may be justified when the target, suitable regimen, and criteria for evaluating the outcome are known. The problem is prescribing it without those conditions.\nWhere Does Treatment End and Ritual Begin? A reasoned approach to treatment follows a sequence:\nObservation → working hypothesis → biological target → choice of preparation and regimen → evaluation of the outcome.\nIf we start at step four and then treat any improvement as confirmation of the diagnosis, we end up in a circular argument. The fish was rubbing against objects → FMC was administered → the fish rubs less → therefore, “FMC treats rubbing.” Yet the original cause remains unknown.\nA treatment bath is a procedure that has been performed. Treatment efficacy is a conclusion that requires evidence.\nThe age of the preparation is beside the point. An old remedy does not become wrong simply because it is old, but neither does long-standing practice prove that an arbitrarily chosen regimen is effective.\nReferences Bassleer, G. (2010). Новый иллюстрированный справочник болезней рыб для декоративных тропических и прудовых рыб [New Illustrated Guide to Fish Diseases for Ornamental Tropical and Pond Fish]. Moscow: Aqua Logo. 232 pp. ISBN 978-5-9902638-1-9. Cited for the historical FMC formulation and treatment regimens; bibliographic details and discussion appear in the full article. Leteux, F., Meyer, F. P. (1972). Mixtures of malachite green and formalin for controlling Ichthyophthirius and other protozoan parasites of fish. The Progressive Fish-Culturist, 34(1), 21–26. DOI. Other levels: F. — the story without technical details · F.O.S. — the full analysis.\n","permalink":"https://fossamethod.ru/en/fo/index_desease/","summary":"Why a ten-minute FMC bath cannot be justified by the product name alone, and what should be checked before and after treatment.","title":"FMC: Why a Treatment Bath Is Not the Same as Effective Treatment"},{"content":"\nDepth of analysis F. F.O. F.O.S. Ten Minutes — and the Fish Is Cured? Imagine a familiar situation in an aquarium. A fish rubs against rocks, there is more mucus on its skin, and it behaves restlessly. What is happening? Perhaps parasites are irritating it. Or perhaps the cause is something entirely different.\nBut the decision has already been made: “Let\u0026rsquo;s give it an FMC bath.”\nThe fish is placed in water containing the treatment for ten minutes and then returned to its aquarium. The procedure is complete. It may seem that all we have to do now is wait for the fish to recover.\nBut what actually happened during those ten minutes? Did the treatment have enough time to affect the parasites? And were parasites even the cause of the problem?\nWhat Is FMC? FMC is the name of a mixture used to treat certain diseases in fish. The formulation discussed here contains:\nFormalin — an aqueous solution of formaldehyde that acts against some external pathogens but can also harm the fish itself. Malachite green — a chemical dye with antiparasitic activity. Methylene blue — another dye with biological activity. Each component has its own properties and limitations. Combining them does not create a universal cure for every disease.\nAnd there is an important distinction: “This product works against some parasites” and “Any bath with this product will help” are not the same claim.\nWhy Ten Minutes Is Not a Magic Number Treatment depends not only on what we add to the water. Just as important are the concentration of the treatment in the water and how long the fish is exposed to it.\nConsider two different approaches. In one, a small amount of the product is added to a large volume of water and left to act for a long time. In the other, a more concentrated solution is used for a short period. These are different exposures, even if the product name on the label is the same.\nWhen the FMC mixture was originally proposed, the approach involved prolonged exposure to a low concentration — for roughly two days. Formalin on its own has also been used in other regimens, including short baths. But that does not mean the exposure time used for formalin alone can automatically be applied to FMC. The details and references are available in the F.O. analysis.\nSo where did those ten minutes come from? If the only answer is “That\u0026rsquo;s how we\u0026rsquo;ve always done it,” then we have a habit, not an explanation.\nWhat If the Fish Looks Better After the Bath? Suppose that by the next day the fish has almost stopped rubbing against rocks. There is less mucus on its skin. Does that mean the FMC worked?\nPossibly. But not necessarily.\nSome parasites may have died or detached. Some of the mucus may have washed away. The fish may have been moved into more suitable water. The irritation may have decreased for an entirely different reason. An improvement in appearance alone cannot tell us exactly what happened.\nThe opposite situation is also possible: the fish looks better, but the pathogen remains. The problem then returns, even though the bath initially seemed successful.\nTo tell these possibilities apart, we should at least try to establish what was present before treatment and what changed afterward. For example, we might examine material from the skin or gills under a microscope, when feasible and justified.\nAn improvement in appearance is an observation. Elimination of the cause of disease is a conclusion that requires additional evidence.\nWhat If Parasites Were Not the Reason the Fish Was Rubbing? Fish can rub against objects for different reasons. That behavior alone tells us neither the name of the disease nor which medicine to use.\nIf we have not identified the cause, then after the bath we cannot confidently say what we were actually treating.\nA particularly troubling possibility is that the parasite is resistant to the chosen treatment or protected within the tissues, while the product further irritates the skin and gills of an already weakened fish.\nIn other words, we tried to fight the disease but placed an additional burden on the animal without solving the original problem.\nSo What Counts as Treatment? A medicated bath is an action. Treatment is an attempt to achieve a particular biological outcome.\nFirst, we need to understand what is happening to the fish. Then we need to decide which cause we intend to address. Only then can we choose an appropriate method and check whether the thing we were trying to change has actually changed.\nSometimes FMC will be a justified choice. Sometimes a completely different intervention will be needed. And sometimes the first step should not be adding a chemical at all, but checking the conditions in the aquarium and investigating the problem.\nWe gave the fish a bath — that\u0026rsquo;s a fact. Whether we cured it remains to be demonstrated.\nThat is why turning treatment into a familiar ritual is dangerous. Not because FMC is “bad” or “outdated,” but because no medicine can replace the question: “What exactly am I treating this fish for?”\nWant to explore the subject in more depth? F.O. — why concentration and exposure time matter more than a familiar product name · F.O.S. — a full analysis of FMC, its history, and the literature.\n","permalink":"https://fossamethod.ru/en/f/index_desease/","summary":"A fish rubs against objects, so it gets an FMC bath. But what did we actually do, and how can we tell whether it helped?","title":"We Gave the Fish a Bath. But Did We Cure It?"},{"content":"\nDepth of analysis F. F.O. F.O.S. “The fish is scratching”: where observation turns into diagnosis A fish suddenly brushes the side of its body against the substrate, sometimes repeating the movement several times. In the literature, this behavior is described as flashing or rubbing. It has been reported in some ectoparasitic infestations, skin diseases, and gill disorders.\nThe movement itself is observable. Yet a familiar explanation often comes before any investigation:\n“The fish is scratching” → “It is scratching its gills” → “So it must have gill parasites.”\nThe first step is an everyday description of behavior. The second is an assumption about the site of irritation. The third is an assumption about its cause. \u0026ldquo;Every new step requires data that motion alone cannot provide.\u0026rdquo;\nThe question is not whether flashing can accompany a parasitic infestation. It can. The question is: how specific is this behavior, and can its characteristics distinguish between possible causes?\nWhy the same behavior need not have the same cause The original F.O.S. article proposes a thought experiment.\nImagine two groups of fish:\nthe first has pronounced irritation of the external surfaces, for example due to a markedly unsuitable pH; the second has confirmed monogeneans on the gills. Suppose both groups rub against the substrate. An observer sees only recordings of their movements, does not know the examination results, and must decide which condition is present in each group.\nIf a specialist is confident that they can distinguish the two, we can ask a testable question: which specific features of the movements are they using? The point of first contact? Head position? Turning angle? Speed? Repetition rate? Association with respiratory movements?\nThose features would then need to be defined in advance and tested against independent video recordings for which diagnoses have been established by other methods. Ideally, the person evaluating the recordings would not know which group each fish belongs to. Only then could we discuss the diagnostic accuracy of the feature, rather than the observer\u0026rsquo;s personal confidence.\nImportant: this is a proposed way to test a hypothesis, not a published experiment demonstrating identical movement patterns under different conditions. The sources cited below do not establish a test capable of reliably distinguishing gill lesions from skin irritation on the basis of a single movement.\nWhat research actually supports Parasites and flashing Garcia et al. (2014) described erratic movements and flashing, among other signs, in rainbow trout affected by gyrodactylid parasites. This shows that rubbing can occur during a parasitic infestation. But observing a sign in infected fish does not mean that it occurs only with that infestation or that it identifies the affected body region without further examination.\nGarcia et al., 2014\nSkin disease and flashing Maddocks et al. (2016) described similar movements in rainbow trout with puffy skin disease, a condition associated with pronounced skin changes. The fish descended to the bottom, rubbed their sides against it, and rapidly righted themselves.\nThis is an important counterexample to the claim that “this movement necessarily means the fish is scratching its gills”: similar behavior has also been described in fish with skin disease.\nMaddocks et al., 2016\nCan water cause irritation without parasites? Mettam et al. (2012) investigated sensory nerve endings in the head region of rainbow trout. They recorded responses to a range of chemical irritants, including acidic solutions and low pH.\nThis provides a physiological basis for considering environmental irritants independently of parasitic infestation. However, the study measured receptor activity, not differences between types of flashing. It cannot be cited as direct experimental evidence that fish exposed to low pH necessarily rub against the substrate in a particular way.\nMettam et al., 2012\nTaken together, these studies support several possible explanations for the behavior, but they do not justify choosing a single cause without investigation.\nCan a fish “scratch its gills”? The gill filaments lie inside the gill chamber, beneath the operculum (gill cover). When a fish makes external contact with a rock or the substrate, it may touch the skin of its head, the operculum, or the region of the gill opening. The gill filaments themselves do not necessarily make contact with the object.\nIt helps to distinguish three statements:\nObservation: the fish makes a sudden rubbing movement against the substrate. Physiological hypothesis: gill irritation may have triggered this motor response. Assumption about the purpose of the movement: the fish is trying to scratch its gill filaments specifically. The second is entirely reasonable as a working hypothesis. The third is a much stronger claim: it assigns a specific purpose to the movement that cannot be inferred from the video alone.\nMoreover, when a gill infestation is present, flashing may coexist with lesions on other external surfaces. Even confirmed gill monogeneans do not establish that every sideways contact with an aquarium decoration is directed specifically at the gills.\nIt is therefore more accurate to say “gill irritation may be accompanied by flashing” than to state categorically that “the fish is scratching its gills.”\nWhich observations are useful, and which are insufficient? A behavioral record can document the frequency of episodes, the side of the body involved, the area of contact, the sequence of movements, environmental conditions, and changes over time. All of these may be useful for subsequent analysis.\nBut the level of detail in an observation is not the same as its diagnostic specificity. Even a high-quality recording cannot, by itself, establish a parasitic cause if the relationship between a particular movement and that cause has not been validated.\nIn practical diagnosis, behavioral observations should be considered alongside other findings and examination results:\nwater parameters and recent changes in husbandry conditions; the condition of the skin, fins, and gill region, and the fish\u0026rsquo;s breathing pattern; how widespread the behavior is among fish in the system and how the signs change over time; when justified, microscopic examination of skin scrapings or appropriate gill samples, taking into account the risks of sampling for the fish. Such examinations help test competing explanations. For example, finding monogeneans is diagnostic evidence in its own right; it does not become evidence merely because the fish appeared to “scratch in a characteristic way.” Conversely, failing to see parasites in a superficial sample does not, by itself, exclude gill disease or other causes.\nObservation, interpretation, diagnosis It is useful to distinguish three levels:\nLevel Example wording What remains unproven Observation “Repeated sudden lateral contacts with the substrate” Why they occur Interpretation “The behavior may be associated with skin or gill irritation” The source and location of the irritation Diagnostic hypothesis “Ectoparasitic infestation should be investigated” The presence and identity of a causative organism A hypothesis is not wrong simply because it has not yet been proven. The error occurs when it is recorded as an established fact.\nWe observe behavior. The cause of that behavior still needs to be demonstrated.\n“You can tell by looking at the fish” may be the starting point of an informed professional suspicion. But for that suspicion to become a diagnostic criterion, we must be able to explain exactly what we are seeing and show how reliably it is associated with the proposed cause.\nReferences and further reading Garcia R. L., Hansen A. G., Chan M. M., Sanders G. E. (2014). Gyrodactylid Ectoparasites in a Population of Rainbow Trout (Oncorhynchus mykiss). Journal of the American Association for Laboratory Animal Science, 53(1), 92–97. Full text. Mettam J. J., McCrohan C. R., Sneddon L. U. (2012). Characterisation of chemosensory trigeminal receptors in the rainbow trout, Oncorhynchus mykiss: responses to chemical irritants and carbon dioxide. Journal of Experimental Biology, 215(4), 685–693. DOI. Maddocks C. E. et al. (2016). Puffy Skin Disease Is an Emerging Transmissible Condition in Rainbow Trout Oncorhynchus mykiss Walbaum. PLOS ONE, 11(7), e0158151. Full text. Other levels: F. — a simple story · F.O.S. — the original in-depth analysis.\n","permalink":"https://fossamethod.ru/en/fo/index_fish_scrab/","summary":"Flashing is observable behavior, not a diagnosis or evidence of where a lesion is located. A thought experiment, the physiology of irritation, and the limits of clinical interpretation.","title":"Fish Rubbing Against Objects: Behavior, Cause, and Diagnosis"},{"content":"\nDepth of analysis F. F.O. F.O.S. The fish is scratching A fish swims up to a rock, suddenly turns sideways, and brushes against it. A little later, it repeats the movement.\n\u0026ldquo;The fish is scratching itself,\u0026rdquo; an observer might say.\nThen perhaps: \u0026ldquo;There must be something wrong with its gills.\u0026rdquo; And after that: \u0026ldquo;It\u0026rsquo;s probably parasites.\u0026rdquo;\nA familiar chain of reasoning. But these are three different claims — and the only thing we actually saw was the movement.\nWhat did we actually see? We saw a fish rub against a surface. This behavior does occur in fish with certain diseases. In scientific studies, it is commonly called flashing or rubbing: a sudden sideways contact with an object or the bottom.\nBut the movement itself does not tell us why the fish did it.\nPerhaps its skin is irritated. Perhaps the problem involves its gills. Perhaps something in the water is affecting it. Or perhaps the cause is something else entirely. The same action does not necessarily have the same cause.\n\u0026ldquo;Scratching\u0026rdquo; is a convenient word in everyday conversation. But it already suggests an explanation we have not yet tested.\nTwo fish, one movement Imagine a test. In one aquarium, a fish has irritated skin because of unsuitable water conditions, such as excessively low pH. In another, a fish has parasitic worms — monogeneans — on its gills.\nNow suppose both fish suddenly rub against the substrate. We are shown only video recordings, without being told what is happening in either aquarium.\nCould we tell from the movement which fish is reacting to the water and which has parasites?\nPerhaps their movements really do differ. But then we need to describe those differences: how the fish turns, which part of its body touches the surface, and how often the movement is repeated. Next, we would need to test whether those features actually help distinguish the causes.\nIf the only explanation is \u0026ldquo;you can just tell,\u0026rdquo; we have an impression, not evidence.\nThis is a thought experiment, not a description of a study that was actually performed. But it shows exactly what kind of evidence is missing.\nCan a fish actually scratch its gills on a rock? Here is where things get interesting.\nThe gills are inside the gill chamber, protected by the gill cover (operculum). When a fish rubs against a rock, it touches the rock with the outside of its body — its skin, head, or gill cover.\nGill irritation really can be associated with this behavior. But that does not mean the fish is physically rubbing its gill filaments against the rock.\nSo there is a difference between these two statements:\n\u0026ldquo;Gill irritation may cause this movement.\u0026rdquo;\nAnd:\n\u0026ldquo;The fish is scratching its gills.\u0026rdquo;\nThe first suggests a possible cause. The second sounds as though we already know exactly what the fish is trying to scratch. We do not.\nWhat should you do if a fish starts rubbing against objects? Do not ignore the behavior. But do not diagnose a disease from a single movement either.\nFirst, look for other changes: how the fish breathes and feeds, what its skin and fins look like, and whether other fish are behaving similarly. Check the water parameters. If there is reason to suspect parasites, examine an appropriate sample under the microscope.\nRubbing against objects is a useful signal to pay attention to the fish, not a ready-made explanation of the cause.\nStudies have described this behavior in fish with parasitic infections (\rGarcia et al., 2014) and in fish with diseases involving marked skin changes (\rMaddocks et al., 2016). The sensitivity of fish nerve endings to chemical irritants, including low pH, has also been studied separately (\rMettam et al., 2012). The latter study supports the possibility of chemical irritation, but does not demonstrate that low pH necessarily causes this particular rubbing behavior.\nWhere observation ends We can confidently say: \u0026ldquo;The fish suddenly brushes its side against the substrate.\u0026rdquo;\nWe can suggest: \u0026ldquo;Perhaps something is irritating it.\u0026rdquo;\nBut to say \u0026ldquo;It\u0026rsquo;s scratching its gills because of monogeneans\u0026rdquo; is to make several assumptions that still need to be tested.\nWe observe the behavior. Its cause still needs to be demonstrated.\nDiagnosis begins with this distinction, not with guesswork.\nWant to explore the subject further? F.O. — how to test an interpretation of fish behavior · F.O.S. — the full analysis with scientific references.\n","permalink":"https://fossamethod.ru/en/f/index_fish_scrab/","summary":"We can see a fish rubbing against rocks. But can we see why? A story about the difference between observation and assumption.","title":"The Fish Is Scratching. But Why?"},{"content":"\nDepth of analysis F. F.O. F.O.S. When Familiar Rods Became Unfamiliar My virtual microscope collection used to contain a specimen simply labeled “Mycobacteria.” Red rods were clearly visible against a blue background. Everything seemed familiar—until I noticed that some of them were branching.\nAnd a question came to mind: how do I know these are actually mycobacteria?\nAfter all, the red color and rod-like shape are things we can see. Naming the bacterium is already a conclusion that needs to be tested.\nSeeing a bacterium is not the same as knowing which bacterium it is.\nWhy Do the “Twigs” Matter? Among bacteria capable of causing disease in fish are Mycobacterium and Nocardia. Mycobacteria more commonly appear as separate rods. Nocardia can form long, branching filaments that subsequently break into shorter fragments.\nBut these differences do not constitute a ready-made identification key. Crossing rods may create the illusion of branching. And Nocardia does not always have to look like twigs.\nTake a look at the two specimens. You can pan and zoom each one independently.\nBrightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off In one specimen, longer structures, some apparently branching, are visible; the other contains small rod-shaped structures. The difference is visible, but their identities have not been established from these images.\nDoesn\u0026rsquo;t Special Staining Give Us the Answer? Ziehl–Neelsen staining helps reveal bacteria that retain the primary dye after acid decolorization. This property is called acid-fastness.\nBut mycobacteria are not the only bacteria that can retain the stain. Some Nocardia species also show this property, although often less consistently.\nIf the specimen was never treated with an acid decolorizer, acid-fastness cannot be assessed at all—even if the bacteria are bright red.\nWhy Does It Matter Which Bacterium We Are Looking At? Because this is not just about putting the right caption under a photograph. Both nocardiae and mycobacteria can cause severe disease in fish, affect internal organs, and produce granulomas. Nocardiosis can cause substantial losses even in freshwater aquaculture. It should not be regarded as a harmless version of mycobacteriosis (Zhang et al., 2024).\nAccurate identification also matters when evaluating possible treatment. Different bacteria—and even different strains of the same species—may have different antibiotic susceptibility profiles. Acid-fast staining does not tell us which drug will work. And even a favorable laboratory susceptibility result does not guarantee recovery in a fish with damaged internal organs.\nWe identify bacteria for more than a name. We need to understand the disease and avoid choosing treatment on the basis of red rods alone.\nSo What Should We Do? First, record what is actually visible: rod-shaped or filamentous structures, their number, distribution, staining, and possible branching.\nThen specify how the specimen was processed. Only after that should we decide which bacteria to investigate and what additional methods are needed to confirm a hypothesis.\nTwigs and rods are observations. Nocardia and Mycobacterium are hypotheses that require testing.\nFor a more detailed explanation: F.O. — morphology and acid-fastness · F.O.S. — investigations, micrographs, and scientific sources.\n","permalink":"https://fossamethod.ru/en/f/twigs_and_sticks/","summary":"Twigs and rods: how to distinguish observation from diagnosis, and why that distinction matters when assessing and treating disease in fish.","title":"Twigs and Rods. Can We Identify Bacteria by Their Shape?"},{"content":"\nDepth of analysis F. F.O. F.O.S. Why the Red Rods Stopped Being “Mycobacteria” For a long time, one of the specimens in my virtual microscope was labeled simply “Mycobacteria.” A closer look, however, revealed that some of the red structures were not merely elongated—some showed apparent branches.\nThat is a good reason to question the familiar label. Staining and shape let us describe morphology and staining characteristics. Neither, by itself, establishes the bacterial genus.\nA red rod is an observation. “This is Mycobacterium” is a hypothesis to be tested.\nNocardia, Mycobacterium, and the Actinomycetes Both Nocardia and Mycobacterium are bacteria. Both belong to the actinomycetes (Actinomycetota) and to the order Mycobacteriales, although they are placed in different families.\nThe term “actinomycetes” can be misleading. Some members grow as branching filaments resembling fungal mycelium. But they are not fungi, nor are all actinomycetes branching bacteria.\nNocardia typically forms branched filaments that may fragment into short rods. Mycobacteria are more commonly rod-shaped. There is no absolute morphological boundary, however: appearance depends on species, cell condition, and specimen preparation.\nHow Can We Tell Whether Branching Is Real? Under the microscope, we should distinguish a continuous branch arising from a single filament from two bacteria merely crossing each other. It is useful to look for similar structures in different parts of the specimen, separate filament fragments, and variations in shape and staining.\nEven clear branching does not automatically mean Nocardia: other branching actinomycetes exist. Moreover, during cultivation, N. seriolae can change from filamentous forms to short rods and coccoid cells (Growth characteristics, 2010).\nYou can compare two specimens yourself. They show two morphotypes, not two conclusively identified bacterial genera.\nBrightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off What Does “Partially Acid-Fast” Mean? This is not a description of shape, nor does it merely mean that a red filament has pale gaps. It concerns whether cells retain the primary stain after exposure to a particular decolorizing solution.\nThe cell envelopes of both Mycobacterium and Nocardia contain mycolic acids, but their composition and structure differ. Many nocardiae exhibit weak or variable acid-fastness: they may retain the dye after gentler decolorization and lose it after more stringent treatment. This is why modified acid-fast methods using milder decolorization, for example 1% sulfuric acid, are often used to detect Nocardia (Brown-Elliott et al., 2006).\nThis does not mean that the standard Ziehl–Neelsen procedure will necessarily decolorize every Nocardia, or that every mycobacterium will invariably retain its color. Species, cell condition, and procedural details all affect the outcome.\nThe central limitation is this: without an acid-decolorization step, acid-fastness has not been tested at all. The appropriate description is then “fuchsin-positive structures,” not “acid-fast bacteria.”\nThe distinction between an observation and what a staining method demonstrates is discussed in “Tradition Instead of Science I. The Method”.\nWhy Can\u0026rsquo;t Granulomas Identify the Genus? Both genera can cause chronic inflammation and granulomatous lesions in fish. White nodules in the spleen or kidneys, even together with red rods, do not automatically establish mycobacteriosis. They justify further investigation.\nIn the study by del Rio-Rodriguez et al. (2021), long branching bacteria and granulomatous lesions were found in red drum. The causative agent was Nocardia seriolae. But this identification did not come from the image alone: culture-based and molecular methods, including sequencing, were used (del Rio-Rodriguez et al., 2021).\nNocardiosis is an important possibility, but without a series of confirmed cases we cannot claim that most large branching rods in freshwater fish are nocardiae.\nDo They Differ in Pathogenicity? Both genera include important fish pathogens. Fish mycobacteriosis is typically a chronic, often slowly progressive infection with granulomatous lesions. Nocardiosis may likewise be chronic and systemic, but can also cause substantial mortality in aquaculture. The simple rule “mycobacteria are dangerous, nocardiae are less dangerous” does not hold.\nIn an experimental infection study of largemouth bass with different Nocardia seriolae isolates, Zhang et al. (2024) reported 70–100% mortality in the groups studied. This reflects the pathogenicity of particular isolates under specific experimental conditions, not a prediction for every infected fish (Zhang et al., 2024).\nNeither the size of granulomas, the severity of organ damage, nor the number of branching structures can therefore serve as a simple genus-level identification rule. We also need information on the host, course of disease, and confirmatory findings.\nWhat About Resistance? Here we must separate two entirely different forms of resistance:\nAcid-fastness in staining is the ability to retain fuchsin after treatment with a decolorizing agent. This is what Ziehl–Neelsen staining and its modifications assess. Antimicrobial resistance is reduced susceptibility to a particular antimicrobial agent. It is assessed separately, for example by determining a minimum inhibitory concentration (MIC), with attention to the validity of the method and the available interpretive criteria. Cell-envelope differences may contribute to both phenomena, but antibiotic susceptibility cannot be inferred from the degree of acid-fastness.\nStudies of fish-derived N. seriolae isolates make this clear. In the Zhang et al. (2024) study, a highly pathogenic isolate was resistant to several β-lactams while remaining susceptible to certain other agents. In Nguyen et al. (2026), 13 isolates showed reduced susceptibility to trimethoprim–sulfamethoxazole according to the thresholds used, whereas results for several other agents were more favorable (Zhang et al., 2024) (Nguyen et al., 2026). Methods and interpretive criteria differ between studies, so their results cannot simply be applied to every isolate.\nEven susceptibility in vitro does not guarantee successful treatment in an aquarium. In systemic granulomatous infections, organ damage, drug penetration into lesions, the fish\u0026rsquo;s condition, and constraints imposed by the life-support system all matter. For fish mycobacteriosis, no generally accepted treatment has been established that reliably eliminates the infection (Merck Veterinary Manual).\nMorphology leads to a hypothesis about the causative agent; identification then informs the assessment of pathogenicity and susceptibility. Not the other way around.\nThree Levels of Description Observation. Rod-shaped and filamentous structures with apparent branching are visible in an impression smear. Demonstrated property. Specify the staining method and whether acid decolorization was performed. Acid-fastness may be reported only when it has been assessed under the stated conditions. Identification. Naming Mycobacterium or Nocardia requires additional evidence: culture, molecular testing, or other validated findings. Branching helps direct the investigation. Staining reveals a response to a particular treatment. Identification requires separate evidence.\nFor the primary research and a fuller comparison of methods, see F.O.S. — “Twigs and Rods” in Detail.\nReferences Brown-Elliott, B.A., Brown, J.M., Conville, P.S., Wallace, R.J. Jr., 2006. Clinical and Laboratory Features of the Nocardia spp. Based on Current Molecular Taxonomy. Clinical Microbiology Reviews, 19(2), 259–282. https://pmc.ncbi.nlm.nih.gov/articles/PMC1471991/\nGrowth Characteristics and Morphological Changes of Fish Pathogen Nocardia seriolae in Submerged Culture, 2010. Aquaculture Science, 58, 429–431. https://doi.org/10.11233/aquaculturesci.58.429\ndel Rio-Rodriguez, R.E., et al., 2021. First evidence of fish nocardiosis in Mexico caused by Nocardia seriolae in farmed red drum (Sciaenops ocellatus, Linnaeus). Journal of Fish Diseases, 44, 1117–1130. https://doi.org/10.1111/jfd.13373\nZhang, W., et al., 2024. Biological characteristics and pathogenicity comparison of Nocardia seriolae isolated from Micropterus salmoides and Channa argus. Frontiers in Veterinary Science, 11, 1367066. https://doi.org/10.3389/fvets.2024.1367066\nNguyen, A.T., et al., 2026. First Report of Nocardiosis Caused by Nocardia seriolae in Farmed Spotted Scat (Scatophagus argus). Journal of Fish Diseases, 49(9), e70171. https://doi.org/10.1111/jfd.70171\nPetty, B.D., Francis-Floyd, R., Yanong, R.P.E., 2024. Bacterial Diseases of Fish. Merck Veterinary Manual. https://www.merckvetmanual.com/exotic-and-laboratory-animals/aquarium-fish/bacterial-diseases-of-fish\n","permalink":"https://fossamethod.ru/en/fo/twigs_and_sticks/","summary":"Why shape does not establish the causative agent, why nocardiosis can be dangerous, and why acid-fastness must not be confused with antibiotic resistance.","title":"Twigs and Rods. What Can Shape and Staining Tell Us?"},{"content":"\nDepth of analysis F. F.O. F.O.S. For a long time, a specimen in my virtual microscope collection had a simple label: “Mycobacteria.” Red rod-shaped structures against a blue background, stained by the Ziehl–Neelsen method. Everything looked familiar—until I examined those structures more carefully.\nSome were not merely elongated rods. They branched. And that raised a question: why had I decided they were mycobacteria in the first place?\nRed rods are an observation. Mycobacteria are an identification. Between the two are several checks that are easy to overlook.\nThis article is not about identifying a pathogen from a single image. It is about why the familiar label “fish TB” can sometimes prevent us from noticing a much more interesting picture.\nAre Actinomycetes Bacteria or Fungi? Bacteria. The name “actinomycetes” is historically associated with filamentous, sometimes branching growth that resembles fungal mycelium. But the resemblance is superficial: neither Nocardia nor Mycobacterium is a fungus.\nBoth genera belong to the broad group Actinomycetota (actinomycetes) and the same order, Mycobacteriales, but to different families: Mycobacterium belongs to Mycobacteriaceae, whereas Nocardia belongs to Nocardiaceae (NCBI Taxonomy: Mycobacterium) (NCBI Taxonomy: Nocardia).\nSo “actinomycetes” is not another name for Nocardia, nor does it refer exclusively to filamentous bacteria. Mycobacteria are actinomycetes too, although they usually appear as individual rods.\nWhat Do We Mean by “Twigs”? Nocardia often grows as thin, branching filaments. These filaments can fragment, leaving separate short rods visible in a specimen. Moreover, cultured N. seriolae has been shown to change morphology with its growth phase: from filamentous cells to short rods and coccoid forms (Growth characteristics, 2010).\nA rod-shaped appearance is more typical of mycobacteria. But shape does not provide an absolute boundary: some species and cell states can show atypical morphology, while overlapping bacteria can create the false impression of branching.\nWhat is worth looking for under the microscope?\nA continuous branch arising from a single filament rather than two separate rods crossing. Filamentous structures with variable thickness and staining. Fragmentation of filaments into shorter elements. Repeated occurrence of similar morphology in different areas of the specimen. These features help formulate a hypothesis, but none independently identifies the bacterial genus.\nBrightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off Why Are Some Bacteria Called “Partially Acid-Fast”? It is easy to misunderstand this term.\nPartial acid-fastness does not mean that a bacterium is only partly rod-shaped or must have patchy staining. It concerns how consistently a cell retains the primary dye after decolorization.\nThe cell envelopes of Mycobacterium and Nocardia contain mycolic acids, but their chemical composition and properties differ. As a result, many nocardiae exhibit weak or variable acid-fastness: the stain may be retained after mild decolorization but partly or completely lost after more stringent treatment. Modified procedures with gentler decolorization are therefore used to detect them (Brown-Elliott et al., 2006).\nBut there is no absolute rule that “standard Ziehl–Neelsen means mycobacteria, while mild acid means Nocardia.” Nocardia can retain the stain even after a Ziehl–Neelsen procedure. The result also depends on the species, physiological condition of the bacteria, and processing conditions.\nIn the publication on Nocardia seriolae in red drum, the authors presented Gram, Ziehl–Neelsen, and Fite–Faraco staining. They interpreted pale regions within the filamentous structures as evidence of partial acid-fastness (del Rio-Rodriguez et al., 2021). That is their interpretation of the images; pale interruptions in someone else\u0026rsquo;s smear are not, by themselves, a reliable way to distinguish bacterial genera.\nIf acid decolorization was omitted altogether, we cannot even call the structures “partially acid-fast.” We are looking at fuchsin-positive structures, but acid-fastness has not been tested.\nFor more on what each stage of staining actually demonstrates, see “Tradition Instead of Science I. The Method”.\nA Case in Which “Mycobacteria” Turned Out to Be Nocardia In their 2021 study, del Rio-Rodriguez and colleagues described a disease outbreak in farmed red drum (Sciaenops ocellatus) in Mexico. Affected fish showed ulcerative lesions and multiple pale nodules in their internal organs, particularly the kidneys and spleen. The farm recorded high cumulative mortality, reaching 70%.\nIn smears, scrapings, and tissue sections, the researchers observed long, branching, sometimes granular-staining bacteria that were Gram-positive and acid-fast. Such findings warranted a differential diagnosis between nocardiosis and mycobacteriosis. But the final identification as Nocardia seriolae did not come from the image: it relied on bacterial isolation, genus- and species-specific PCR, and gyrB gene sequencing (del Rio-Rodriguez et al., 2021).\nBranching suggested looking for Nocardia. Identification required other methods.\nWhat About Granulomas? Don\u0026rsquo;t They Mean “Fish TB”? No. Granulomatous inflammation is a tissue response, not the name of a pathogen. Both mycobacteria and nocardiae can produce severe granulomatous lesions in fish. In their 2018 review, Maekawa and colleagues described nocardiosis as a disease affecting the skin, muscles, and internal organs of teleost fish (Maekawa et al., 2018).\nTherefore, “pale nodules in the kidneys + red rods in a smear” does not automatically justify a diagnosis of “mycobacteriosis.” It justifies further investigation, not a confirmed species-level identification.\rTraditions Instead of Science IV. Diagnosis.\rGranulomas, necrosis, and mycobacteriosis in fish: why similar morphological findings do not imply the same etiology and cannot, on their …\rUntil we have a set of confirmed cases, we cannot claim that large rods in freshwater fish are more often nocardiae or that Nocardia and Mycobacterium occur in a “50/50” ratio. Observing different morphotypes across different specimens is a useful starting point for research, not a prevalence estimate.\nHow Do the Diseases Differ When We Consider Pathogenicity Rather Than Shape? This is where the comparison becomes useful in practice. Accurate morphological description is not merely about giving a photograph a convincing caption. Similar-looking granulomatous lesions may be caused by different pathogens, with different epidemiology and antimicrobial susceptibility profiles.\nFish mycobacteriosis is most often described as a chronic, progressive infection. It may involve wasting, skin changes, lesions in the kidneys, spleen, and other organs, and the formation of granulomas. The causative species differ in growth rate and biological characteristics. For example, Mycobacterium marinum is a recognized fish pathogen that can also infect humans through damaged skin (Merck Veterinary Manual).\nNocardiosis can also be a chronic systemic infection. Common findings include multiple white nodules in organs, areas of necrosis, and skin lesions. Nocardia must not be considered less pathogenic merely because it is not Mycobacterium. Zhang and colleagues (2024), for example, investigated ten N. seriolae isolates recovered from freshwater fish—largemouth bass (Micropterus salmoides) and northern snakehead (Channa argus). In some experimentally infected groups, mortality reached 70–100% (Zhang et al., 2024).\nThis does not mean that every Nocardia infection will cause such mortality. Pathogenicity depends at least on the bacterial species and strain, the fish species and its condition, the route and dose of infection, and husbandry conditions. But the example demonstrates that the severity of disease alone cannot reliably distinguish nocardiosis from mycobacteriosis.\nPathogenicity should not be confused with the number of stained rods, either. More intense staining, longer filaments, or larger granulomas are not direct measures of virulence. Nor does mortality on a farm, by itself, identify the pathogen.\nResistance: To Acid, Antibiotics, or Environmental Conditions? The word “resistance” may cause more confusion here than the micrographs themselves.\nAcid-fastness is a staining characteristic. It describes retention of dye following a specified treatment and is influenced, among other factors, by the lipid-rich cell envelope. Antibiotic resistance is a different property: reduced susceptibility to a particular antimicrobial agent through specific cellular mechanisms. Persistence of infection within the host is yet another issue: a pathogen may remain in tissues and granulomatous lesions even when laboratory tests suggest susceptibility to certain drugs.\nIf a bacterium retains fuchsin after acid treatment, we have learned nothing about whether doxycycline, florfenicol, or another agent will work against it.\nBoth genera have cell envelopes containing mycolic acids, but this does not give them identical drug-susceptibility profiles. Relevant differences must be assessed at the species and isolate level. Likewise, merely detecting genes associated with possible resistance does not replace phenotypic susceptibility testing.\nN. seriolae provides a useful example. In the Zhang et al. (2024) study, one of the most pathogenic isolates was resistant to the tested β-lactam agents but susceptible to several antibiotics of other classes (Zhang et al., 2024). In the study by Nguyen et al. (2026), 13 isolates from diseased fish showed reduced susceptibility to trimethoprim–sulfamethoxazole according to the thresholds applied, whereas the florfenicol and oxytetracycline results fell within the wild-type population (Nguyen et al., 2026). These findings do not constitute a ready-to-use treatment table: the studies examined different isolates, used potentially different methods and interpretive criteria, and clinical breakpoints for many fish pathogens remain limited.\nFish mycobacteriosis is also difficult to manage. Beyond the pathogen\u0026rsquo;s biological properties, chronic infection and poorly accessible lesions complicate treatment. According to the Merck Veterinary Manual, treatments that reliably eradicate mycobacterial infection in fish are not available in routine practice (Merck Veterinary Manual).\nResistance to disinfectants is a third, separate question. A Ziehl–Neelsen result cannot tell us which disinfection procedure will work for the system, equipment, or surfaces. Such decisions require evidence concerning the active ingredient, concentration, contact time, and organic load.\nWhat Does This Change in Aquarium Practice? Diagnostic investigation. Branching Gram-positive structures with variable acid-fastness are a reason to include Nocardia in the differential diagnosis, rather than labeling every granuloma as mycobacteriosis. Risk assessment. A confirmed pathogen, the extent of lesions, and the condition of other fish matter more than a single striking “twig” in a smear. Specimen handling. When systemic bacterial infection is strongly suspected, appropriate material should ideally be retained for culture and molecular testing instead of relying solely on a red-stained slide. Treatment. Even identification to genus level does not replace susceptibility testing or an assessment of whether an effective drug concentration can be reached in affected tissues without unjustified harm to the fish or the aquarium life-support system. Staff safety. When handling fish suspected of having mycobacteriosis, the known zoonotic risk of certain species, especially M. marinum, must be considered (Merck Veterinary Manual). That level of risk should not automatically be attributed to every Nocardia species. Now we can see why distinguishing “twigs” from “rods” matters. Not to diagnose by shape, but to select the right tests and avoid the wrong treatment decision.\nWhat Should We Do with an Unusual Specimen? Start by describing exactly what is visible rather than substituting the name of a bacterium.\nObservation: fuchsin-positive rod-shaped or filamentous structures; note any apparent branching, granular staining, or isolated fragments.\nMethod: whether acid decolorization was performed, which procedure was used, and what controls were included. A positive Ziehl–Neelsen result demonstrates acid-fast staining under the conditions used, not bacterial identity.\nIdentification: if determining the pathogen is important to the diagnosis, additional evidence is needed—for example, Gram staining, bacterial isolation, or molecular identification. Even convincing branching on a micrograph does not replace confirmation.\nAn appropriate description of an unconfirmed finding might be:\n“Fuchsin-positive rod-shaped and filamentous structures with apparent branching were observed in a spleen impression smear. The morphology is compatible with branching actinomycetes, including members of the genus Nocardia. Genus-level identification has not been established.”\nIf acid decolorization was not performed, that must be stated separately, and the structures must not be described as acid-fast.\nInstead of a Conclusion We are accustomed to seeing red rods and mentally adding “mycobacteria.”\nShape suggests what to investigate. Staining demonstrates a property under particular conditions. Naming the pathogen requires evidence.\nThat is precisely why we should show and document what is actually observed, even when definitive identification remains unavailable.\nReferences del Rio-Rodriguez, R.E., et al., 2021. First evidence of fish nocardiosis in Mexico caused by Nocardia seriolae in farmed red drum (Sciaenops ocellatus, Linnaeus). Journal of Fish Diseases, 44, 1117–1130. https://doi.org/10.1111/jfd.13373 Maekawa, S., Yoshida, T., Wang, P.-C., Chen, S.-C., 2018. Current knowledge of nocardiosis in teleost fish. Journal of Fish Diseases, 41, 413–419. https://doi.org/10.1111/jfd.12782 Growth Characteristics and Morphological Changes of Fish Pathogen Nocardia seriolae in Submerged Culture, 2010. Aquaculture Science, 58, 429–431. https://doi.org/10.11233/aquaculturesci.58.429 Brown-Elliott, B.A., Brown, J.M., Conville, P.S., Wallace, R.J. Jr., 2006. Clinical and Laboratory Features of the Nocardia spp. Based on Current Molecular Taxonomy. Clinical Microbiology Reviews, 19(2), 259–282. https://pmc.ncbi.nlm.nih.gov/articles/PMC1471991/ Zhang, W., et al., 2024. Biological characteristics and pathogenicity comparison of Nocardia seriolae isolated from Micropterus salmoides and Channa argus. Frontiers in Veterinary Science, 11, 1367066. Experimental pathogenicity of freshwater-fish isolates and antibiotic susceptibility testing. https://doi.org/10.3389/fvets.2024.1367066 Nguyen, A.T., et al., 2026. First Report of Nocardiosis Caused by Nocardia seriolae in Farmed Spotted Scat (Scatophagus argus). Journal of Fish Diseases, 49(9), e70171. Thirteen isolates, variation in MIC values, and limitations of applying interpretive thresholds. https://doi.org/10.1111/jfd.70171 Petty, B.D., Francis-Floyd, R., Yanong, R.P.E., 2024. Bacterial Diseases of Fish. Merck Veterinary Manual. Fish mycobacteriosis: clinical course, treatment limitations, and the zoonotic risk associated with certain species. https://www.merckvetmanual.com/exotic-and-laboratory-animals/aquarium-fish/bacterial-diseases-of-fish NCBI Taxonomy. Mycobacterium (Taxonomy ID 1763). https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=1763 NCBI Taxonomy. Nocardia (Taxonomy ID 1817). https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=1817 ","permalink":"https://fossamethod.ru/en/posts/twigs_and_sticks/","summary":"What branching and acid-fastness reveal about bacteria in fish, why nocardiosis is not necessarily milder than mycobacteriosis, and how to assess antimicrobial susceptibility.","title":"Twigs and Rods. Who Are We Looking at in This Specimen?"},{"content":" Select a specimen Click any specimen to view — Loading image… Annotations: Off Specimen collection ","permalink":"https://fossamethod.ru/en/microscope-app/","summary":"Wide-screen virtual microscope with DZI specimens and annotations.","title":"Virtual Microscope — Wide View"},{"content":"\nDepth of analysis F. F.O. F.O.S. “Fin Rot”: A Diagnosis or a Description of Appearance? Irregular fin edges, shortened rays, whitish areas, and damaged fin membranes are often grouped under the familiar term “fin rot.” This is convenient in everyday conversation. In diagnosis, however, it creates a problem: the name itself already suggests an infectious cause, even though all we may have observed is tissue damage.\nThe same external change may result from trauma, a non-infectious pathological process, or a bacterial infection. These possibilities are not always mutually exclusive: microorganisms may colonize tissue that has already been damaged.\nIt is therefore useful to begin with three separate questions: what is damaged, how is the damage developing, and what caused it?\nFin damage is a morphological finding. Bacterial infection is one possible cause. The former does not automatically imply the latter.\nWhat Is a Fin Ray Made Of? Structure of fin rays. A — segmented lepidotrichia. B — cross-section of a lepidotrichium showing its two half-segments. The supporting structures of bony fish fins are called lepidotrichia. They are segmented rays, not solid rods. Each lepidotrichium consists of two curved half-segments. Successive segments along the ray are connected by ligaments; connective tissue, blood vessels, and nerves lie between the half-segments. The entire structure is surrounded by the soft tissues of the fin (\rSharples \u0026amp; Evans, 1996).\nThis combination of rigid elements and flexible connections gives the ray both strength and flexibility. But when the connections between its components are damaged, the segments may separate, split apart, or fragment. This does not necessarily mean that bacteria are directly destroying each of these elements.\nWhat Does the Dissecting Needle Demonstrate? Ваш браузер не поддерживает видео. Separation of a damaged fin ray under a stereomicroscope In the video, the needle is applied to an already damaged fin ray. Its individual components separate along their connections, while some of the soft tissue remains intact in the area examined. Two conclusions need to be distinguished here.\nObservation: the components of a damaged ray can separate under mechanical force. We can therefore observe a particular pattern of structural breakdown.\nCause not established: why the tissues and their connections were damaged before the needle was applied. Answering that requires information about the fish, its environment, and the nature of the lesion. The demonstration shows how the components separate when force is applied, but proves neither an infectious nor a non-infectious origin for the initial damage.\nFin Erosion Without a Primary Bacterial Infection The term fin erosion is used in scientific literature. It describes the breakdown of fin tissues, but the word “erosion” does not, by itself, establish an etiology: erosion may also occur in infectious diseases.\nA particularly illustrative example is the study by Sharples and Evans (1996). The authors examined fin damage in goldfish (Carassius auratus) living in a section of river affected by pulp and paper mill effluent. Tissue examination allowed them to trace the sequence of pathological changes.\nThe outer epidermal structures were affected first: surface features were lost, and epithelial cells began to slough off. Changes in deeper tissues and the lepidotrichia appeared later. Substantial bacterial involvement was not found in most of the lesions examined; bacteria that were detected were considered likely secondary (\rSharples \u0026amp; Evans, 1996).\nWhat does this example demonstrate? A fin can deteriorate without an established primary bacterial infection. It does not prove that every similar lesion develops by the same mechanism or is necessarily associated with water pollution.\nWhat If the Problem Is Nutrition or the Fish\u0026rsquo;s Overall Condition? Fin condition depends on more than the rigid rays. The integrity of the epithelium, connective tissue, and blood vessels, as well as tissue nutrition and the capacity for repair, are also important.\nDietary imbalances, disturbances in mineral metabolism, and the fish\u0026rsquo;s general physiological condition are reasonable areas to investigate. But it is easy to jump to another premature conclusion: seeing damaged fin tips and immediately attributing them to “poor tissue nutrition.”\nImpaired tissue nutrition is a hypothesis that needs testing, not a label for every case of non-infectious erosion. In particular, general findings on mineral metabolism in fish do not demonstrate that the distal parts of fins must always be damaged first because of inadequate blood supply (\rLall \u0026amp; Kaushik, 2021).\nA lack of evidence for a bacterial cause is not evidence for any one particular non-infectious cause.\nWhen Bacteria Contribute to Fin Destruction Bacteria found in infectious fin lesions. Left — filamentous forms; right — small rod-shaped bacteria. Bacterial diseases affecting fins do exist. In columnaris disease, associated with bacteria of the Flavobacterium columnare group, lesions of the skin, gills, and fins — including fin erosion — have been described (\rDeclercq et al., 2013). In such cases, microorganisms may be direct participants in the pathological process.\nBut secondary bacterial processes also occur. Tissue is first damaged for another reason, and microorganisms subsequently colonize the altered surface. This is to be expected: fish are constantly exposed to diverse microbial communities, while their mucus and epithelium contribute to local defense (\rGomez et al., 2013).\nWhen interpreting a microscopic preparation, we need to consider not only whether bacteria are present, but also their distribution, their relationship to the damaged tissues, signs of inflammation, and the course of the disease. Finding large numbers of bacteria in a damaged area does not automatically tell us which event came first.\nTwo Different Scenarios Primary bacterial lesion: microorganisms contribute to the onset and progression of tissue damage.\nSecondary colonization: the lesion develops first, and bacteria multiply on an already altered surface, potentially causing further complications.\nBoth scenarios are possible. In each case, the task is to determine which one best explains the observations.\nA Practical Approach: Where to Start Instead of immediately prescribing a “fin rot treatment,” it is useful to assess several aspects in sequence:\nMorphology. Which structures are damaged: the edges of the fin membrane, individual rays, or the fin base? Is there redness, a coating, mucus, necrosis, or hemorrhage? Progression. Did the damage develop rapidly or gradually? Is it still progressing? Distribution. Is one fish affected, a particular species, or many fish within the same system? Environment and injuries. Have there been changes in water conditions, filtration, equipment, transfers, aggression, or injuries during capture? Microscopy. What is happening to the soft tissues? Which microorganisms are present, and how are they associated with the affected area? If the findings suggest an infectious process, identifying the causative agent may require targeted sampling, bacterial culture, molecular testing, or histology. Yet even when these methods are unavailable, describing the tissues, performing microscopy, and examining husbandry conditions can narrow the range of possible explanations.\nThe limitations of the examination also matter: seeing bacteria does not establish their causal role, and failing to find bacteria in a single preparation does not completely rule out infection.\nFrom Observation to Diagnosis We can document: “The edge of the caudal fin is irregular, individual rays are shortened, and the membrane between them is damaged.”\nWe can propose: “The lesion is consistent with fin erosion; traumatic, environmental, and infectious causes should be investigated.”\nBut stating “this is bacterial fin rot” requires independent supporting evidence, not merely a similar external appearance.\nA diagnosis should explain the origin of the damage, not merely restate its appearance in different words.\nFirst, describe the fin damage. Next, investigate the possible mechanisms. Only then decide what treatment is actually needed.\nReferences Sharples, A. D., Evans, C. W. (1996). Pathology of fin erosion in goldfish Carassius auratus. Diseases of Aquatic Organisms, 24, 81–91. https://doi.org/10.3354/dao024081 Declercq, A. M. et al. (2013). Columnaris disease in fish: a review with emphasis on bacterium-host interactions. Veterinary Research, 44, 27. https://doi.org/10.1186/1297-9716-44-27 Gomez, D., Sunyer, J. O., Salinas, I. (2013). The mucosal immune system of fish: the evolution of tolerating commensals while fighting pathogens. Fish \u0026amp; Shellfish Immunology, 35, 1729–1739. https://doi.org/10.1016/j.fsi.2013.09.032 Lall, S. P., Kaushik, S. J. (2021). Nutrition and metabolism of minerals in fish. Animals, 11, 2711. https://doi.org/10.3390/ani11092711 Other levels: F. — a simple story about frayed fins · F.O.S. — full analysis and original research.\n","permalink":"https://fossamethod.ru/en/fo/finerosion/","summary":"From visible signs to underlying mechanisms: what the separation of lepidotrichia reveals, when bacteria cause fin damage, and how to investigate alternative explanations.","title":"Fin Damage: Erosion, Infection, and Fin-Ray Structure"},{"content":"\nDepth of analysis F. F.O. F.O.S. Has Something \u0026ldquo;Eaten Away\u0026rdquo; a Fish\u0026rsquo;s Fin? A fish once had a beautiful, smooth-edged fin. Then its edge became uneven and frayed. After a while, individual rays began sticking out in different directions, and the fin grew shorter.\n\u0026ldquo;Fin rot,\u0026rdquo; someone will say in an aquarium chat. And they will almost certainly recommend a treatment against bacteria.\nBut what have we actually learned? We\u0026rsquo;ve seen a damaged fin. We haven\u0026rsquo;t seen what caused the damage.\nThe word \u0026ldquo;rot\u0026rdquo; makes it sound as though someone has already established that microorganisms are breaking down the tissue. Yet a similar appearance can result from injury, certain noninfectious disorders, or a genuine bacterial infection.\nA frayed fin is a sign of damage, not an explanation of its cause.\nLet\u0026rsquo;s Take a Closer Look at the Fin Structure of fin rays. A — segmented lepidotrichia. B — cross-section of a lepidotrichium showing two hemisegments. A fin is not a single solid sheet. It is supported by thin rays made up of many interconnected parts. Soft tissues lie between the rays.\nThis is especially clear under magnification.\nNow let\u0026rsquo;s take an already damaged fin ray and gently touch it with a dissecting needle. Watch what happens.\nВаш браузер не поддерживает видео. How the Parts of a Damaged Fin Ray Separate The ray seems to come apart into separate pieces. At the same time, some of the soft tissues can still be seen intact in the area being examined.\nIt almost looks as though we\u0026rsquo;ve caught the fin in the act of breaking down. But there\u0026rsquo;s a catch: the needle shows how already damaged parts separate. It doesn\u0026rsquo;t show what damaged them in the first place.\nPerhaps the fish was injured. Perhaps the surrounding tissues were affected first. Or perhaps an infection really was developing. This demonstration alone cannot tell us which explanation is correct.\nCan a Fin Break Down Without Bacteria? Yes. Researchers studied goldfish living in a stretch of river affected by wastewater from a pulp and paper mill. The fish had damaged fins, but the researchers found little evidence of substantial bacterial involvement in the process.\nTissue examination showed that the changes began in the fin\u0026rsquo;s outer covering, then spread to deeper tissues and the rays themselves. This is one documented example of noninfectious fin erosion (\rSharples \u0026amp; Evans, 1996).\nThe opposite can happen, too. In columnaris disease, for example, bacteria can indeed cause lesions of the skin, gills, and fins (\rDeclercq et al., 2013).\nSo both possibilities are real. The mistake is treating either one as the only possible explanation for every frayed fin.\nWhat Should You Do if a Fish\u0026rsquo;s Fins Are Deteriorating? First, find out what\u0026rsquo;s happening to the fish and its aquarium.\nLook at when the changes began and how quickly they are progressing. Are there injuries, other fish chasing it, or dangerous parts of the equipment? Is only one fish affected, or several? Have the water parameters, filtration, or keeping conditions changed?\nIf you have access to a microscope, examining the damaged area can help: which tissues remain intact, are there signs of inflammation, and what microorganisms can you see? But even if you find bacteria, that doesn\u0026rsquo;t automatically tell you whether they appeared before the damage or colonized the tissue afterward.\nDon\u0026rsquo;t choose an antibacterial treatment based on the fin\u0026rsquo;s appearance alone. First, establish whether there is good reason to suspect a bacterial disease.\nWhat Have We Learned? We started with a familiar term: \u0026ldquo;fin rot.\u0026rdquo; Then we looked at the structure of a fin ray and watched its parts separate under a dissecting needle.\nBut the most important part didn\u0026rsquo;t happen under the microscope. We separated what we actually observed from what we merely suspect.\nThe fin is damaged — that\u0026rsquo;s a fact. Why it was damaged is a question that still needs investigating.\nWant to explore further? F.O. — how fin rays are built and how erosion differs from infection · F.O.S. — the full scientific analysis with research references.\n","permalink":"https://fossamethod.ru/en/f/finerosion/","summary":"A frayed fin is often immediately called fin rot. But what have we actually observed, and why isn\u0026rsquo;t that enough for a diagnosis?","title":"Frayed Fins. Who's to Blame?"},{"content":"\n“By the toll of a billion deaths, man had earned his immunity —\nhis right to survive among this planet’s infinite organisms.” War of the Worlds (2005), final monologue. Presentation on this topic\rПоказания и ограничения к применению лекарственных препаратов в аквариумных системах\rAn organism is often called healthy when nothing “bad” is found in it: parasites, bacteria, fungi, injuries, or deviations from an assumed norm. Yet a living organism does not exist separately from its environment. Its body surface, gills, intestine, and even internal tissues constantly interact with other organisms. Absolute sterility is therefore not a natural state for an animal (Gomez et al., 2013).\nHealth is not the absence of all foreign organisms. It is the ability to preserve function, maintain internal balance, and compensate for environmental effects without a pronounced loss of condition.\nAn organism may be infected without being diseased.\nThe presence of a pathogen is not the same as disease Detecting a parasite or bacterium answers only one question: the organism is present in the examined material. It does not yet show:\nwhether it is causing the observed changes; how numerous it is; whether the host can control its effects; whether it is the main cause of the disorder; whether immediate treatment is required. A single ciliate on the surface of a fish and tens of thousands of ciliates on its skin and gills are biologically very different situations, even though the name of the finding is the same.\nIn natural environments, fish regularly carry small numbers of external parasites. Detecting them does not mean that every such fish is diseased. Otherwise, a substantial proportion of wild animals would have to show severe clinical signs continuously.\nThe boundary between carriage and disease is determined not by the mere presence of an agent, but by the consequences of its presence.\nDisease begins not when a parasite appears, but when its effects exceed the host’s capacity to cope.\nImmunity controls, but does not necessarily eliminate The immune system is often imagined as an army whose task is to find and completely destroy everything foreign. Yet continuous full mobilisation against every microorganism would be too costly and too dangerous for the host itself.\nA defensive response requires energy, alters circulation, increases mucus production, recruits inflammatory cells, and may damage the animal’s own tissues. The organism therefore does not have to respond with equal intensity to a single parasite and to a massive infection.\nIn many cases, the outcome of an immune response is not sterility but controlled coexistence (Luo et al., 2007; Bai et al., 2008; Yin et al., 2015):\nparasite numbers remain low; tissue damage is limited; organ function is preserved; clinical signs are absent or minimal. This is not a failure of immunity. On the contrary, maintaining balance may be more advantageous than a destructive attempt to eliminate every last cell.\nA defensive response also has a cost Mucus protects the skin and gills of fish. However, excessive mucus production may also impair gas exchange and retain parasites, bacteria, and cellular debris. Inflammation limits infection, but marked oedema and cellular infiltration damage tissues. Sloughing of epithelium helps remove an affected layer but disrupts the integrity of the body surface (Dash et al., 2018).\nThe intensity of a defensive response therefore does not always directly reflect the number of pathogens. In a susceptible species, even a relatively low parasite burden may cause marked skin cloudiness, increased respiratory effort, and behavioural changes. Another fish carrying the same number of parasites may remain almost normal in appearance (Yin et al., 2018).\nThe severity of the condition is therefore determined not only by the aggressiveness of the parasite, but also by the way in which the host responds.\nSometimes an animal is harmed not only by the pathogen, but also by an excessive attempt to defend itself against it.\nAn aquarium can turn presence into disease In nature, a parasite that leaves a fish enters an enormous volume of water. Its next stage may fail to encounter a suitable host, be carried away by currents, die, or settle far from the fish.\nIn an aquarium, the situation is different:\nthe volume of water is limited; animal density is high; the same surfaces are used repeatedly; detached stages accumulate near the host; water movement returns them to the zone occupied by the skin and gills of fish; the same fish encounters the offspring of parasites that were recently living on it. A parasite that existed in nature as a low-intensity infection may, in a closed system, repeatedly complete its cycle on the same animals.\nDisease in an aquarium is therefore often associated not with the arrival of an entirely new pathogen, but with changes in space, density, and the probability of repeated contact.\nAn aquarium does not merely contain a fish and a parasite. It changes the probability that they will meet (How et al., 2015).\nThe absence of signs does not prove the absence of a parasite After treatment, a fish may look clean, breathe normally, and resume feeding. This is an important clinical result. But it does not prove that no viable stage remains on the fish or in the system. Acquired protection can sharply reduce the intensity of subsequent infection and its clinical consequences (Luo et al., 2007; Yin et al., 2015).\nWe see disease only after a certain threshold has been exceeded. While parasite numbers remain low, they may:\ncause no visible clouding of the skin; cause no marked hypersecretion of mucus; be detected only inconsistently in a limited skin scrape; persist in folds, beneath scales, in the gills, or in other difficult-to-sample locations; pass between fish at an intensity below the clinical threshold. The disappearance of symptoms therefore means that the animal’s condition has improved, but not necessarily that the agent has been completely eliminated.\nBelow the detection threshold does not mean equal to zero.\nNot every finding must be destroyed immediately When a ciliate, bacterium, or fungus is found in a skin scrape, the natural reaction is to add a medication immediately. But the decision should not depend only on the name of the organism that was found.\nThe following must be considered:\nthe condition of the fish; infection intensity; lesion location; progression over time; species susceptibility; water quality; the possibility of direct treatment; the risk posed by the treatment itself; consequences for the whole system. A single finding in a fish behaving normally and a massive infection in an animal that is breathing heavily and has stopped feeding should not automatically lead to the same treatment protocol (Yin et al., 2018).\nA medication is required not because other life is present in the system, but because further damage to the animal is expected without intervention.\nA wound in water remains a wound — but water does not make it a catastrophe Damage to a fish’s skin remains in constant contact with water. To a human observer this seems unusual: we try to protect our own wounds from contamination and prolonged wetting. As a result, the mere appearance of a wound under water may be perceived as an emergency.\nFish, however, are evolutionarily adapted to this environment. A small, clean wound may close on its own under appropriate conditions. Not every lesion requires an antibiotic, an antiseptic applied to the entire system, or a prolonged course of medication.\nFirst, it is necessary to determine:\nwhether tissue destruction is continuing; whether necrosis is present; whether inflammation is increasing; whether fungal or bacterial growth has appeared; whether the animal’s general condition is deteriorating; whether the lesion can be cleaned directly. If pathological material is accessible, it can be removed. If a wound is clean and healing, normal water quality and observation may sometimes be the best course of action.\nTreat the loss of balance The existence of parasites, bacteria, and fungi is not a mistake of nature. Hosts and the organisms around them evolved through constant interaction. Immunity, body surfaces, mucus, behaviour, and tissue repair all developed in a world that was never sterile.\nThe aim of treatment should therefore not be formulated as the destruction of all other life around the animal.\nThe aim is to return the system to a state in which:\nthe fish remains viable; damage is not progressing; the parasitic or bacterial burden is controlled; repeated infection is limited; treatment does not cause more harm than the original problem. Treatment should target not the presence of other life, but the loss of balance that makes this presence dangerous.\nReferences Bai J. S., Xie M. Q., Zhu X. Q., Dan X. M., Li A. X. 2008. Comparative studies on the immunogenicity of theronts, tomonts and trophonts of Cryptocaryon irritans in grouper. Parasitology Research, 102(2): 307–313. https://doi.org/10.1007/s00436-007-0766-6\nDash S., Das S. K., Samal J., Thatoi H. N. 2018. Epidermal mucus, a major determinant in fish health: a review. Iranian Journal of Veterinary Research, 19(2): 72–81. PMID: 30046316; PMCID: PMC6056142.\nGomez D., Sunyer J. O., Salinas I. 2013. The mucosal immune system of fish: the evolution of tolerating commensals while fighting pathogens. Fish \u0026amp; Shellfish Immunology, 35(6): 1729–1739. https://doi.org/10.1016/j.fsi.2013.09.032\nHow K. H., Zenke K., Yoshinaga T. 2015. Dynamics and distribution properties of theronts of the parasitic ciliate Cryptocaryon irritans. Aquaculture, 438: 170–175. https://doi.org/10.1016/j.aquaculture.2014.12.013\nLuo X. C., Xie M. Q., Zhu X. Q., Li A. X. 2007. Protective immunity in grouper (Epinephelus coioides) following exposure to or injection with Cryptocaryon irritans. Fish \u0026amp; Shellfish Immunology, 22(4): 427–432. https://doi.org/10.1016/j.fsi.2006.04.011\nYin F., Sun P., Tang B., Dan X., Li A. 2015. Immunological, ionic and biochemical responses in blood serum of the marine fish Trachinotus ovatus to poly-infection by Cryptocaryon irritans. Experimental Parasitology, 154: 113–117. https://doi.org/10.1016/j.exppara.2015.04.010\nYin F., Liu W., Bao P., Jin S., Qian D., Wang J., Tang B. 2018. Comparison of the susceptibility and resistance of four marine perciform fishes to Cryptocaryon irritans infection. Fish \u0026amp; Shellfish Immunology, 77: 298–303. https://doi.org/10.1016/j.fsi.2018.03.052\n","permalink":"https://fossamethod.ru/en/posts/health-is-not-sterility/","summary":"Health is not the absence of all microorganisms and parasites, but the ability of an organism to preserve its functions and resilience while continuously interacting with the environment.","title":"Health Does Not Mean Sterility"},{"content":" At least two clinical situations are possible in cryptocaryonosis. In the first, the parasite is detected early: its numbers are still low, and the fish retains normal respiration, behaviour, and appetite. In this situation there is time to target the free-living stages in the water, control the concentration of the selected treatment, and gradually reduce contamination of the system.\nIn the second situation, the disease is already severe. The fish is breathing heavily, is covered with large amounts of mucus and parasites, refuses food, and may die before treatment of the water produces a result.\nThese situations are not opposed to one another. Successful assistance to a severely affected fish should move it from the second state into the first: first reduce the parasite burden rapidly and restore vital functions, then continue treatment of the system and control the remaining stages of the parasite.\nThis page is devoted specifically to the second situation — when the fish is already in distress. Why the presence of a parasite does not always mean disease, and why health does not mean sterility\rHealth Does Not Mean Sterility\rWhy the presence of microorganisms and parasites does not always mean disease, why immunity does not have to eliminate them completely, and …\rWhat should be done if the fish may die before the treatment in the water takes effect? Adding copper to the water does not immediately remove trophonts from the skin and gills. Even a correctly calculated and controlled concentration acts within the parasite\u0026rsquo;s life cycle and requires time (Zec et al., 2021).\nFor the system, this may be a justified treatment. For a fish that is suffocating, it is too slow as the first intervention.\nThis is not an argument against copper or other methods of treating the water. It is an argument about the sequence of actions. When the fish is severely affected, waiting for a drug to act should not replace direct assistance to the animal.\nTreatment should therefore be divided into two stages:\nImmediate assistance to the fish and rapid reduction of the parasite burden; Subsequent control of the parasite in the water and prevention of reinfection. Reduce the burden on the fish first The severity of the condition is determined not only by the fact of infection, but also by the number of parasites present on the skin and gills at that moment. The greater the burden, the more severe the irritation of the body surface, mucus production, epithelial damage, and respiratory impairment (Kaige \u0026amp; Miyazaki, 1985; Cervera et al., 2022).\nTherefore, when the condition is severe, the first objective is not to destroy every parasite in the system immediately, but to reduce their number directly on the fish as quickly as possible.\nEven incomplete parasite removal can change the situation substantially. If only several hundred parasites remain on the skin and gills instead of thousands, the immune system, body surface, and respiratory organs gain time to recover. The fish may begin to breathe more effectively, maintain equilibrium, and survive the period required for further treatment.\nComplete elimination of the parasite may take time.\nReduction of the burden on the fish should begin immediately.\nMethods acting directly on the body surface may include:\nA short bath in an appropriate solution; Rinsing; Removal of excessive pathologically altered mucus; Careful mechanical cleaning of accessible areas of skin; Treatment of individual lesions; Transfer of the fish to a clean container after the procedure. The method must be selected according to the fish species, the condition of its body surface, the location of the lesions, and the animal\u0026rsquo;s ability to tolerate restraint and treatment.\nThis does not mean roughly scraping normal epithelium. The material removed should primarily be material that has already ceased to perform a protective function: accumulations of parasites, loose mucus, detached epithelium, and superficial pathological deposits.\nMore information: direct handling of fish and mechanical removal of external parasites\rSimple Rules for Working with Aquarium Fish\rBasic guidelines for diagnosing and caring for aquarium fish: what to do in case of mortality, how to interpret appetite, and when to treat …\rWhy parasites appear on the fish in waves Trophonts of Cryptocaryon irritans feed and grow on the skin and gills of the fish. After completing this stage, they leave the host, settle on surfaces, and continue their development outside the fish (Colorni \u0026amp; Diamant, 1993; Ma et al., 2016).\nIn an aquarium, these stages do not disappear. They accumulate on the bottom, walls, equipment, and other surfaces. After division, new infective stages emerge and search for a host. Recently emerged theronts pose the greatest risk: as they age, their motility and ability to infect fish decline rapidly (Yoshinaga \u0026amp; Dickerson, 1994; Chi et al., 2020).\nThe number of visible parasites on a fish may therefore change in waves:\nSome trophonts leave the fish, and its external appearance temporarily improves; Development continues outside the host; A new generation emerges from the accumulated stages; The fish becomes reinfected, sometimes much more heavily than before. A temporary decrease in the number of white spots on the fish does not necessarily mean that the disease has ended.\nIt may simply reflect the transition of the parasite to the next stage of its life cycle (Li et al., 2022).\nThe fish remains close to the site of parasite development After leaving the host, some stages of Cryptocaryon irritans settle, attach to aquarium surfaces, and continue developing outside the fish (Colorni, 1985; Colorni \u0026amp; Diamant, 1993). Fish may remain directly on or close to the bottom for long periods, only a few centimetres from accumulations of the parasite. The host therefore remains close to the site from which the next generation of infective stages emerges. The limited water volume and short distance increase the probability of reinfection.\nThe fish remain directly on the aquarium bottom, close to the surface on which stages of Cryptocaryon irritans settle and continue their development. Petri dishes after exposure on the aquarium bottom. The visible deposits contained numerous attached stages of Cryptocaryon irritans. What has left the fish remains in the system. Petri dishes were placed on the bottom of an aquarium containing infected fish. Material accumulated on their surfaces that could easily have been mistaken for ordinary sediment or contamination. Under magnification, this material contained numerous attached stages of Cryptocaryon irritans.\nAccumulations of attached stages On the surfaces of the Petri dishes, the parasites occurred not only individually but also in dense multilayered accumulations. These areas formed films that, without magnification, could be mistaken for ordinary organic deposits.\nDense multilayered accumulation of attached stages of Cryptocaryon irritans. Individual structures form continuous areas of deposit. Attached stages of Cryptocaryon irritans on the surface of a Petri dish. At higher magnification When examined in transmitted light, rounded and oval structures surrounded by an outer wall are clearly visible. The internal contents of individual stages are heterogeneous, consistent with continuing development outside the host.\nAccumulation of encysted stages of Cryptocaryon irritans examined in transmitted light. Encysted stages of Cryptocaryon irritans at higher magnification. The outer wall and heterogeneous internal contents are visible. Parasites are removed together with mucus When shedding of pathologically altered mucus was intensified, parasites left the fish surface together with dense mucus masses and cells of detached epithelium. They were present in large numbers in this material and often formed compact accumulations.\nAccumulation of Cryptocaryon irritans in dense mucus and detached epithelium removed from the surface of the fish. Parasites within a detached mucus-cell mass. Removing pathologically altered mucus simultaneously reduces the parasite burden on the fish surface. What appears externally to be mucus, sediment, or a film on a surface may contain large numbers of viable parasite stages.\nParasites that have left the fish do not disappear. Some remain in mucus and detached epithelium, while others attach to aquarium surfaces and continue developing outside the host. Temporary clearing of the skin therefore does not mean that the life cycle has stopped: unless the accumulated material is removed, the fish soon remains close to a new generation of infective stages (Burgess \u0026amp; Matthews, 1994).\nThese observations demonstrate a simple point: a decrease in the number of parasites on the fish does not mean that they have disappeared. A substantial part of the life cycle continues close to the host, within the same restricted system.\nAction scheme: clean the fish and separate it from the parasite If the fish is already heavily infected, treatment must address two objectives at the same time:\nrapidly reduce the number of parasites on the skin and gills; prevent the fish from immediately encountering the next generation of infective stages. A treatment added to the water does not remove trophonts from the fish immediately. Its action is directed primarily at free-living stages of the parasite. In a severe case, waiting for treatment of the water to take effect may therefore be too slow.\nFirst remove as much as possible of what is on the fish now. Then separate the fish from what remains in the system.\n1. Direct treatment of the fish When the species tolerates brief exposure to freshwater, this can be used to rinse the body surface and reduce the parasite burden.\nThe duration of the procedure must be determined by the condition and species-specific sensitivity of the fish. It should not be treated as a bath that the animal must endure at any cost. In some cases, a few minutes are sufficient to rinse the fish carefully while removing detached mucus and superficial pathological material.\nIn severe infestations, one procedure may not be sufficient. Several hours after the first treatment, intensified shedding of mucus and detached epithelium may begin. The fish can then be rinsed again to remove material that has already separated from the body surface.\nMore information: direct handling of fish and mechanical removal of external parasites\rSimple Rules for Working with Aquarium Fish\rBasic guidelines for diagnosing and caring for aquarium fish: what to do in case of mortality, how to interpret appetite, and when to treat …\rThe inability to remove every parasite in a single procedure is not a reason to leave all parasites on the fish.\n2. Do not return the cleaned fish to accumulated parasite stages After rinsing, the fish should be placed in a clean container. Returning it immediately to the same untreated aquarium restores contact with cysts, mucus, detached epithelium, and the infective stages emerging from them.\nTwo approaches are possible:\ntransfer the fish to another prepared container; temporarily remove the fish, drain the aquarium completely, clean the aquarium and equipment, and then refill it. The second option is particularly useful when only a small number of treatment tanks is available. The aquarium is then used not as a permanently contaminated environment, but as a container that can be repeatedly cleared of accumulated parasite stages.\n3. Repeat transfer and cleaning The more often the fish is separated from contaminated surfaces and newly emerged infective stages, the more strongly transmission of the parasite is disrupted (Colorni, 1985).\nIn theory, more frequent changes of container would be more effective than infrequent changes. In practice, every restraint, bath, and transfer imposes an additional burden on the fish. The frequency of procedures must therefore be chosen as a compromise between parasite removal and the animal\u0026rsquo;s tolerance of intervention.\nFor many fish, one complete treatment and transfer per day may already reduce reinfection substantially. The decision should take into account:\nseverity of the condition; rate at which parasites reappear; tolerance of restraint and freshwater exposure; ability to maintain stable parameters in replacement containers; quality of aquarium cleaning between transfers. Transfer works not because it “treats” the fish, but because it physically leaves part of the parasite\u0026rsquo;s life cycle behind.\n4. Separate the fish from the bottom An elevated mesh platform separates the fish from the bottom, where attached stages of Cryptocaryon irritans may accumulate. Theronts have limited motility: the maximum recorded upward swimming speed was 1.6 mm/s, and most theronts in the experiment were found within the lower five-centimetre layer of water. Increasing the distance between the fish and the bottom may therefore reduce the probability of reinfection (How et al., 2015).\nA mesh platform can be installed above the bottom for this purpose. The mesh opening should be as large as possible while still preventing the fish from passing through. The mesh itself should have as little surface area as possible: thin structural elements reduce the area available for attachment of parasite stages.\nThe platform does not kill the parasite. It reduces the likelihood of direct contact between the fish and the surfaces on which the parasite accumulates and continues developing.\nThe purpose of the mesh is not to filter the water, but to prevent the fish from resting directly on a contaminated surface.\n5. After stabilisation — treatment of the water Physical removal of parasites and transfer to a clean container do not eliminate the need for further control of the system. Once the fish has stabilised, copper or another selected method can be used to target the free-living stages of the parasite.\nThe sequence, however, matters:\nfirst reduce the burden on the fish; remove accumulated material from the environment; limit reinfection; then target the remaining stages in the water. Why “provoking emergence” with urea is questionable Urea is sometimes proposed to stimulate the mass emergence of infective stages of Cryptocaryon irritans into the water, after which the released theronts are expected to be killed by a treatment. This scheme assumes that a large proportion of the parasites will enter the water simultaneously and be destroyed before they reach a host.\nUrea has been investigated as an attractant for theronts that have already emerged and could potentially be used together with a trap, not as a proven means of synchronously inducing theront emergence from tomonts (Skilton et al., 2020).\nA treatment concentration that is safe for the fish does not necessarily act instantaneously. If adding urea does increase the number of infective stages in the water, some may reach the fish and intensify infection before they are killed.\nSuch provocation is therefore meaningful only when it has been demonstrated that:\nthe intervention really induces sufficiently synchronous emergence; the treatment kills the released stages rapidly enough; the effective concentration is maintained accurately; the fish is physically protected from contact with the released theronts. When the fish can instead be transferred and the aquarium drained and cleaned, deliberately increasing the number of parasites in the water becomes an additional risk that is difficult to justify.\nIt is simpler to remove the fish from the parasite\u0026rsquo;s emergence zone than first to increase the number of infective stages and then attempt to kill them next to the host.\nThe main objective is to interrupt reinfection The meaning of the entire scheme lies not in any single procedure, but in the sequential separation of fish and parasite. First, as many parasites as possible are removed from the body surface. The fish is then moved into clean water, the container is cleared of settled stages, and the animal is physically separated from the bottom where development of the parasite continues.\nThe objective is to make reinfection as unlikely as possible and the conditions for parasite persistence as unfavourable as possible.\nThe fewer parasites remain on the fish, the fewer viable stages persist in the environment, and the less often they reach the host again, the more time the animal gains for recovery. Subsequent treatment of the water then acts not against a continuously increasing infestation, but within a system in which the parasite\u0026rsquo;s life cycle has already been disrupted as much as possible.\nReferences Burgess P. J., Matthews R. A. 1994. Cryptocaryon irritans (Ciliophora): photoperiod and transmission in marine fish. Journal of the Marine Biological Association of the United Kingdom, 74(3): 535–542. https://doi.org/10.1017/S0025315400047652\nCervera L., González-Fernández C., Arizcun M., Cuesta A., Chaves-Pozo E. 2022. Severe natural outbreak of Cryptocaryon irritans in gilthead seabream produces leukocyte mobilization and innate immunity at the gill tissue. International Journal of Molecular Sciences, 23(2): 937. https://doi.org/10.3390/ijms23020937\nChi H., Goldstein M., Pichardo A., Wei Z.-H., Chang W.-J., Gong H. 2020. Infectivity and genes differentially expressed between young and aging theront cells of the marine fish parasite Cryptocaryon irritans. PLOS ONE, 15(8): e0238167. https://doi.org/10.1371/journal.pone.0238167\nColorni A. 1985. Aspects of the biology of Cryptocaryon irritans, and hyposalinity as a control measure in cultured gilthead sea bream Sparus aurata. Diseases of Aquatic Organisms, 1: 19–22. https://doi.org/10.3354/dao001019\nColorni A., Diamant A. 1993. Ultrastructural features of Cryptocaryon irritans, a ciliate parasite of marine fish. European Journal of Protistology, 29(4): 425–434. https://doi.org/10.1016/S0932-4739(11)80405-0\nHow K. H., Zenke K., Yoshinaga T. 2015. Dynamics and distribution properties of theronts of the parasitic ciliate Cryptocaryon irritans. Aquaculture, 438: 170–175. https://doi.org/10.1016/j.aquaculture.2014.12.013\nKaige N., Miyazaki T. 1985. A histopathological study of white spot disease in Japanese flounder. Fish Pathology, 20(1): 61–64. https://doi.org/10.3147/jsfp.20.61\nLi Y., Jiang B., Mo Z., Li A., Dan X. 2022. Cryptocaryon irritans (Brown, 1951) is a serious threat to aquaculture of marine fish. Reviews in Aquaculture, 14(1): 218–236. https://doi.org/10.1111/raq.12594\nMa R., Ni B., Fan X., Warren A., Yin F., Gu F. 2016. Ultrastructure observation on the cells at different life history stages of Cryptocaryon irritans (Ciliophora: Prostomatea), a parasitic ciliate of marine fishes. Parasitology, 143(11): 1479–1489. https://doi.org/10.1017/S0031182016001074\nSkilton D. C., Saunders R. J., Hutson K. S. 2020. Parasite attractants: identifying trap baits for parasite management in aquaculture. Aquaculture, 516: 734557. https://doi.org/10.1016/j.aquaculture.2019.734557\nYoshinaga T., Dickerson H. W. 1994. Laboratory propagation of Cryptocaryon irritans on a saltwater-adapted Poecilia hybrid, the black molly. Journal of Aquatic Animal Health, 6(3): 197–201. https://doi.org/10.1577/1548-8667%281994%29006%3C0197%3ALPOCIO%3E2.3.CO%3B2\nZec S., Hadfield C. A., Hungerford L. 2021. Retrospective review of copper sulfate immersion treatment in marine teleosts during quarantine at the National Aquarium of Baltimore from 2004 to 2016. Journal of Zoo and Wildlife Medicine, 52(1): 97–102. https://doi.org/10.1638/2020-0114\nSee also ","permalink":"https://fossamethod.ru/en/posts/cryptocaryon-control/","summary":"In severe cryptocaryonosis, the first task is to keep the fish alive and reduce the number of parasites on its body; only then should the remaining life cycle of Cryptocaryon in the system be targeted.","title":"Cryptocaryonosis: killing the parasite or treating the water?"},{"content":"This page brings together scientific articles, conference materials, and supplementary resources related to fish disease diagnostics, aquatic animal pathology, and the analysis of aquarium systems.\nEach entry includes a brief description and links to available full-text versions, supplementary data, photographs, or video materials.\nScientific Articles 2026 Clinical Manifestations and Course Patterns of Cryptocaryonosis (Cryptocaryon irritans) in Marine Fish under Aquarium Conditions Stepankov A. P. Clinical manifestations and course patterns of cryptocaryonosis (Cryptocaryon irritans) in marine fish under aquarium conditions // Biota and Environment of Natural Areas. 2026. Vol. 14, No. 2. P. 82–90. DOI: 10.25221/2782-1978_2026_2_8.\nThe study examines two distinct patterns of cryptocaryonosis: a form with visible lesions on the body surface and a gill form in which external signs may be absent. It explains why the absence of white spots does not rule out severe gill involvement.\nMaterials on Fossa Method\rCryptocaryon irritans: Not Just White Spots\rCryptocaryon irritans. is a ciliated protozoan parasite, often visible to the naked eye. Tangs, butterflyfish, and boxfish are particularly …\rRead: on the journal website · Video and supplementary materials · DOI\nThe Role of Length–Weight Relationships in Monitoring and Optimisation of Fish Husbandry: Experience from the Primorsky Aquarium Stepankov A. P. The role of length–weight relationships in monitoring and optimisation of fish husbandry: experience from the Primorsky Aquarium // Biota and Environment of Natural Areas. 2026. Vol. 14, No. 2. P. 66–75. DOI: 10.25221/2782-1978_2026_2_6.\nThe study focuses on the use of length–weight relationships to assess fish condition in aquarium settings. It considers the limitations of small samples, interspecific differences, and the potential use of accumulated measurements for practical monitoring.\nRead: on the journal website · DOI\nConference Materials 2026 Indications and Limitations for the Use of Medicinal Products in Aquarium Systems A. P. Stepankov. Indications and limitations for the use of medicinal products in aquarium systems. International Scientific and Practical Conference “Ocean in the City”, Moskvarium Centre for Oceanography and Marine Biology, Russia, 28 February–1 March 2026.\nThe paper examines the methodological basis for assessing the appropriateness of pharmacological therapy in aquarium systems from an ecosystem perspective. It is shown that, in closed aquarium systems, medicinal products affect not only the fish organism but also the microbiological, chemical, and physical parameters of the environment, which substantially limits the predictability of pharmacokinetics and therapeutic effects.\nThe limitations of hepatoprotective and probiotic preparations under aquarium conditions are analysed, and their low effectiveness in the absence of elimination of aetiological factors and a controlled route of administration is demonstrated. Particular attention is paid to the effects of auxiliary components of tablet formulations on organic loading and the microbiological balance of the system.\nThe conclusion emphasises the need for a rational, diagnostically justified approach to pharmacological interventions, prioritising the correction of husbandry conditions and the maintenance of aquarium ecosystem stability.\nInformation: Presentation\r· Conference page\nRead: ISTINA\n2025 In Vivo Diagnostics of Fish in Aquarium Conditions: Health Monitoring and Modern Methods A. P. Stepankov. In vivo diagnostics of fish in aquarium conditions: health monitoring and modern methods. International Scientific and Practical Conference “Ocean in the City”, 7–8 February 2025, Moskvarium Centre for Oceanography and Marine Biology, Russia.\nMethods of in vivo fish diagnostics in aquarium settings are described, including skin scrapings, gill washes, and the examination of faecal samples. Procedures for sample collection, labelling, and transportation are presented, together with the use of microscopy to detect parasites, bacteria, and fungus-like organisms. The importance of regular monitoring for the early detection of pathological processes and the assessment of fish condition without euthanasia is emphasised.\nPresentation\r· Conference page\nDocumenting Microprocesses as a Tool for Empirical Analysis and as an Educational Resource in Aquarium Practice and Fish Pathology A. P. Stepankov. Documenting microprocesses as a tool for empirical analysis and as an educational resource in aquarium practice and fish pathology. In: Marine Biology in the 21st Century: Proceedings of the All-Russian Conference in Memory of Academician Alexey Viktorovich Zhirmunsky, pp. 253–255. National Scientific Center of Marine Biology, Far Eastern Branch of the Russian Academy of Sciences, Vladivostok, 2025.\nThe use of photographic and video documentation of microprocesses in aquarium practice and fish pathology is considered. Digital recording of microscopic objects and processes makes it possible to preserve visual data, compare observations over time, identify patterns, and use the resulting materials for subsequent analysis.\nParticular attention is paid to documenting fish egg development, the morphological features of microscopic objects, and the microscopic appearance of pathological processes. The educational value of such materials is also discussed: they make it possible to demonstrate dynamic phenomena that are difficult to reproduce during a conventional lesson and help specialists develop observation and interpretation skills.\nDigital photographs and videos can therefore serve both as an empirical basis for research and as a universal educational resource.\nFlying Elephants\rFlying Elephants\rWhy science requires more than an elegant hypothesis. The role of photographs, videos, specimens, and primary data in building and verifying …\rWhat Counts as Evidence in the Age of Artificial Intelligence?\rWhat Is Your Evidence?\rWhy photographs, videos, and polished explanations are no longer enough in the age of generative AI. A practical look at provenance, …\rRead: eLibrary · Conference page\nIntegration of Biological and Environmental Parameters in a Database: From Routine Record-Keeping to Scientific Analysis A. P. Stepankov. Integration of biological and environmental parameters in a database: from routine record-keeping to scientific analysis. In: Proceedings of the XIV International Scientific and Practical Conference “Marine Research and Education (MARESEDU-2025)”, Vol. III (IV), Vol. 3 of the series Proceedings of the International Scientific and Practical Conference “Marine Research and Education (MARESEDU)”, pp. 279–287. PoliPRESS LLC, 2025.\nThe paper presents experience in developing a universal database for the integrated recording of aquatic animals in an aquarium setting. The system combines information on animal deliveries and transfers, feeding, morphometric measurements, mortality, and environmental parameters.\nParticular attention is paid to the use of standard length, the construction of aquarium-specific length–weight relationships, and the monitoring of actual feed consumption. Linking biological and environmental data makes it possible to assess population and growth dynamics, identify critical periods, adjust diets and husbandry conditions, and conduct retrospective analyses.\nThe integration of heterogeneous observations into a single system transforms routine record-keeping into a tool for monitoring, analysing, and predicting the condition of animals in artificial ecosystems.\nRead: ISTINA · Conference page · Presentation\r2024 Clinical Cases of an Atypical Form of Cryptocaryonosis A. P. Stepankov. Clinical cases of an atypical form of cryptocaryonosis. V International Conference “The Public Aquarium in the Modern World”, Saint Petersburg, 28–30 May 2024.\nCases of atypical cryptocaryonosis in marine fish are examined in which visible white spots are absent and the principal lesions develop in the gills. An analysis of publications demonstrates how the repeated reproduction of simplified descriptions of clinical signs can cause differences between forms of the disease to remain unnoticed. The need to consider the gill form and not to restrict diagnosis to external examination alone is emphasised.\nInformation: Presentation\r· Conference page · Materials on Fossa Method\rCryptocaryon irritans: Not Just White Spots\rCryptocaryon irritans. is a ciliated protozoan parasite, often visible to the naked eye. Tangs, butterflyfish, and boxfish are particularly …\r2023 Integrated Solutions for Data Collection, Processing, and Output Used at the Primorsky Aquarium Stepankov A. P. Integrated solutions for data collection, processing, and output used at the Primorsky Aquarium. In: Interdepartmental Collection of Scientific and Methodological Papers “Problems of Aquaculture: Aquarium Science and Aquarium Exhibitions”, Vol. 7, pp. 34–39. Aqua Logo Engineering LLC, Moscow Zoo, EARAZA, SOZAR, Moscow, 2024.\nAn approach to organising an integrated system for data collection, storage, and analysis in an aquarium setting is described. The integration of MariaDB, Microsoft Access, spreadsheet software, and the R programming language provides centralised information storage, access control, automated reporting, and statistical data processing.\nThis architecture reduces the time required to retrieve and process information, improves system flexibility, and simplifies interaction between departments.\nRead: eLibrary · Conference page\nSee Also Ichthyophthiriosis\rIchthyophthiriosis Without Myths\rA science-based analysis of Ichthyophthirius multifiliis: life cycle, cyst terminology, the myth of parasite ubiquity, and real mechanisms …\rHexamita\rHexamitids Without Myths\rWhy hexamitids are not a normal component of fish intestinal microflora, where the myth of 'internal parasites' comes from, and how …\rWhat to Do with Fish after Arrival\rInitial Diagnostics After Fish Transportation\rMicroscopy, smears, staining methods, and common mistakes in early diagnostics.\r","permalink":"https://fossamethod.ru/en/publications/","summary":"Articles, conference proceedings, and supplementary materials with brief descriptions and links to full texts.","title":"Publications"},{"content":"\nIntroduction Gas bubble disease (GBD) is a condition in which free gas bubbles form in the blood and tissues of fish. It leads to impaired microcirculation, gill damage, organ destruction, and in some cases, death.\nA common explanation — “air bubbles entered the gills and blocked them” — is incorrect. It replaces the actual mechanism and prevents proper interpretation of both clinical signs and necropsy findings.\nA detailed explanation of the mechanism is provided here\rGas Bubble Disease: It\u0026#39;s Not About the Bubbles\rGas Bubble Disease in fish is not caused by air bubbles entering the gills but by dissolved gas supersaturation. This article explains the …\r.\nWhy diagnosis is difficult Gas bubble disease does not always produce obvious signs: bubbles may be absent, disappear after death, be sparse, or have no diagnostic value, as noted in broader analyses of gas bubble trauma in fish (Pleizier et al., 2020).\nAcute cases with clearly visible bubbles are the exception rather than the rule.\nIn most situations, the process is chronic and subtle, remaining unnoticed externally.\nWhere the problem originates In systems with pumps, pressure often exceeds atmospheric levels. This increases gas solubility in water. If air is entrained at the pump intake, or if cavitation or microbubbles are present, a gas–water mixture is formed.\nThis results in gas supersaturation, which in closed aquatic systems is considered one of the key drivers of gas bubble disease (Hong et al., 2024).\nIn acute cases, this may lead to rapid mortality with obvious signs:\ngas in the eyes bubbles in fins gas accumulation in body cavities However, this is not the typical scenario.\nWhat actually happens Under chronic supersaturation, gas exchange becomes impaired. Oxygen may still enter tissues, but inert gases (primarily nitrogen) are not effectively eliminated. They accumulate in dissolved form (Pleizier et al., 2020).\nThis leads to:\nmicrocirculatory disruption blood stasis development of ischemia followed by tissue hypoxia Despite the presence of blood in the organs, it does not perform its function.\nThe presence of blood in a tissue does not indicate effective circulation.\nWhat this leads to With prolonged exposure, a sequential cascade develops:\nimpaired gas exchange microcirculatory disturbances ischemia hypoxia tissue destruction The most sensitive organs are:\ngills kidney brain These are the structures most commonly affected during necropsy.\nIschemia is a condition in which tissue experiences oxygen deficiency due to impaired blood supply or microcirculation.\nImportant The presence of gas in tissues at necropsy is not, by itself, evidence of gas bubble disease.\nPostmortem gas bubbles may form due to:\nwarming of the body autolysis pressure changes This is especially noticeable when fish are kept in cold water but examined at higher temperatures. As temperature increases, gas solubility decreases, and dissolved gases come out of solution, forming bubbles.\nThus, the presence of gas at necropsy reflects not only processes that occurred during life, but also changes that develop after death.\nContext is more important than individual findings.\nConsequences. Macro- and microscopic picture The fish heart pumps venous blood. Circulation is single-loop: blood passes through the gills for gas exchange, then distributes to tissues and returns to the heart.\nThe heart directs blood flow toward the head. Because vessels are located close to the surface in the rostral region, circulatory disturbances may become visually apparent.\nBlood stasis is associated with:\nredness vascular engorgement dilation hyperemia Hyperemia in the oral and rostral region.\rSuch a finding is not specific and does not, by itself, indicate an infectious process.\rGas in the vessels of gill filaments.\rBlood then passes through the gills. The gills are among the most sensitive organs to gas embolism, as shown in experimental and morphological studies (Pleizier \u0026 Brauner, 2024). They are highly reactive structures. When microcirculation is impaired, blood stasis develops, gas exchange efficiency decreases, and tissue ischemia occurs. In severe cases, this leads to necrosis.\rNecrosis is cell death occurring during life.\nDegeneration refers to tissue breakdown after death.\nDilated vessels and hemorrhages in the brain. Blood then reaches the brain.\nMicrocirculatory disturbances lead to venous congestion, increased pressure, and vascular damage. These changes reflect the development of ischemia in nervous tissue. The kidney in fish consists of head and trunk regions.\nThe trunk kidney lies along the позвоночник beneath the swim bladder and contains renal tubules — the main functional structures. A large volume of blood passes through it, so microcirculatory disturbances quickly lead to pronounced changes.\nTypical findings include:\nhyperemia tubular destruction tissue necrosis Normal morphology of the trunk kidney in fish. The image shows a compression preparation of the trunk (posterior) kidney of a fish. In contrast to the head kidney, which primarily performs hematopoietic and immune functions and is composed of loose hematopoietic tissue, the trunk kidney is responsible for the excretory function. Its structure is characterized by a well-developed tubular system: the tubules are clearly distinguishable, with defined contours and open lumens. For this reason, any changes — hyperemia, tissue destruction, or loss of structure — should be assessed primarily in relation to the condition of these tubules. Disruption of this architecture underlies the pathological changes observed.\nThus, this image can be considered a morphological baseline, serving as a reference point for the interpretation of pathological findings.\nMarked hyperemia and hemorrhages. Tubules partially preserved. Tissue destruction: tubules poorly distinguishable. Severe damage: parenchyma appears homogeneous, structure lost. In chronic GBD, fish may survive long enough to reach such stages. Mortality during handling or transfer in these cases reflects pre-existing damage rather than a primary cause.\nChanges in the eye. Gas bubbles.\nThe head kidney is primarily hematopoietic and does not contain renal tubules. However, hyperemia may occur under microcirculatory disturbances. Nearby structures include the eyes, where gas may accumulate depending on species.\nFindings include hyperemia, hemorrhages, and gas accumulation.\nGas in the atrium. Gas in the atrium.\nGas bubbles may also be observed in the heart, although this is more typical in cases of pronounced supersaturation.\nGas in blood. Gas in blood.\nIf bubbles are visible in the heart, this may indicate a high level of dissolved gases in the blood. When such blood is transferred with a pipette, gas is released actively and becomes clearly visible. Under normal conditions, blood does not readily form stable foam, and gas release is minimal.\nConclusions Gas bubble disease cannot be reduced to the presence of bubbles in tissues. It is primarily a disorder of microcirculation and gas exchange that may develop without obvious macroscopic signs. The absence of bubbles at necropsy does not exclude the diagnosis. Conversely, their presence does not confirm it without considering system conditions and clinical history.\nThe main changes develop gradually and are associated with impaired blood supply. This leads to ischemia, followed by hypoxia and subsequent tissue destruction. The most sensitive organs are the gills, kidney, and brain.\nThe presence of blood in an organ does not indicate normal function. Vascular engorgement may reflect congestion and impaired outflow rather than adequate circulation. Many necropsy findings require careful interpretation. Gas in tissues may form after death and is not always related to processes occurring during life.\nA diagnosis cannot be based on a single sign. It requires integration of morphological findings, environmental conditions, and the history of clinical signs.\nUnderstanding the mechanism is more important than memorizing individual features. Only this allows differentiation between cause and consequence and helps avoid common diagnostic errors.\nReferences Hong, W.H., Choi, J.Y., Cho, H.S., Im, J., Park, S.C., Seok, S.H., Kim, S.W., 2024. Gas bubble disease in captive Golden Trevally: Pathological insights and needs for life support system and water quality management. J Aquat Anim Health 36, 348–354. https://doi.org/10.1002/aah.10237 Pleizier, N., Algera, D., Cooke, S., Brauner, C., 2020. A meta-analysis of gas bubble trauma in fish. Fish and Fisheries 21. https://doi.org/10.1111/faf.12496 Pleizier, N.K., Brauner, C.J., 2024. Causes and consequences of gas bubble trauma on fish gill function. J Comp Physiol B 194, 739–747. https://doi.org/10.1007/s00360-024-01538-4 FAQ Is gas in tissues proof of disease? No. It may form postmortem.\nWhy do organs appear congested? Due to blood stagnation, not normal circulation.\nWhy are bubbles sometimes absent? Because the process is often subclinical.\nWhich organs are most affected? Gills, kidneys, and brain.\nCan diagnosis rely on a single sign? No. Context and multiple findings are required.\nSee also: ","permalink":"https://fossamethod.ru/en/posts/bubble_diagnoz/","summary":"A practical approach to fish necropsy: what is normal, what may be variation, and what indicates pathology.","title":"Gas Bubble Disease. Part II. Consequences."},{"content":"\nCoccidia are regularly encountered in fish, but in most cases remain unnoticed. Their detection requires targeted microscopic examination, as macroscopic signs are either absent or nonspecific.\nGoussia sp. Goussia sp. Goussia sp.\nThe images show coccidia parasitizing the intestinal wall of Amur chebachok.\nOocysts are oval, approximately 10–15 µm in size, with a well-defined wall. Inside, four sporocysts can be identified. Their content consists of elongated sporozoites, clearly visible in native preparations.\nUnder the microscope, oval oocysts with a dense wall are clearly distinguished. Sporocysts occupy most of the internal volume. Notably, the internal organization is well preserved — structures do not disintegrate and retain their shape, which distinguishes them from cellular debris.\nIn some preparations, three sporocysts can be observed within a single oocyst. Each contains its own internal structures, including elongated sporozoites. It is important to assess not only the shape of the oocyst, but also its internal architecture — this is what allows differentiation from other inclusions.\nGoussia sp. Goussia sp.\nStained preparations highlight the oocyst wall, although internal structures may become less distinct. In such cases, interpretation should rely on overall shape, size, and repeatability of the observed structures. Uniform staining does not exclude the presence of parasites.\nWhen observing groups of oocysts, the consistency of shape and size becomes evident — one of the key indicators of a parasitic origin. Sporocysts are elongated, and their content is aligned along the longitudinal axis, which is characteristic of Goussia.\nOocysts with clearly visible sporocysts allow identification of elongated sporozoites. These worm-like structures are among the most reliable diagnostic features and should not be confused with artifacts or degraded tissue.\nThe key diagnostic feature is the internal organization. In contrast to Eimeria, where sporocysts have a distinct wall and appear more compact, in Goussia sporozoites are seen as structured elongated forms without a clearly separated sporocyst wall.\nParasites localize in the intestinal epithelium and undergo intracellular development. This is associated with epithelial damage, desquamation, and accumulation of mucus in the intestinal lumen. At moderate infection intensity, coccidia may not produce obvious clinical signs. However, with increased parasite load or weakened host condition, digestive disturbances, emaciation, and mortality may occur.\nIt is important to note that coccidia do not induce granuloma formation. The presence of granulomatous inflammation should prompt investigation of other causes and should not be interpreted as coccidiosis.\rInterpretation The presence of coccidia in the intestine does not always indicate disease. Evaluation of infection intensity and tissue condition is essential.\nSingle oocysts may be considered incidental findings. A high number of intracellular stages accompanied by epithelial destruction indicates a pathological process.\nThe presence of sporulating forms within tissue suggests an active life cycle rather than incidental ingestion of oocysts from the environment.\nDifferential diagnosis The main challenge is distinguishing Goussia from Eimeria.\nEimeria is characterized by sporocysts with a clearly defined wall. Their internal content typically appears as a compact granular mass.\nGoussia, in contrast, lacks a well-defined sporocyst wall, and elongated sporozoites are clearly visible, forming characteristic worm-like structures inside the oocyst.\nCryptosporidium differs by its much smaller size and localization on the epithelial surface, without formation of sporocysts.\nPractical relevance Coccidia are part of the hidden microfauna of aquarium systems. They may persist in a population for long periods without causing overt disease, but under changing conditions can rapidly become clinically significant.\nWithout microscopy, such processes remain undetected and are often interpreted as “unexplained” disturbances.\nRegular monitoring allows early detection of these infections and a more accurate assessment of their significance for fish health.\n","permalink":"https://fossamethod.ru/en/posts/goussia/","summary":"Oocysts with elongated sporozoites are characteristic of Goussia. Microscopy-based interpretation and diagnostic features.","title":"Fish coccidia: Goussia"},{"content":"\nRound structures with a distinct clear halo are periodically observed in fish preparations.\nVisually, they resemble encapsulated yeast-like forms and may be associated with cryptococci. However, morphological similarity alone is insufficient for diagnosis.\nThis page presents observations of such structures and an attempt at careful interpretation in context.\nComparison with literature data In the classical presentation, cryptococci appear as round cells with a prominent capsule, often showing budding and localizing within tissues, including inside macrophages.\nObservation Round structures with a distinct halo. In native preparations, round elements with a clearly defined peripheral halo are observed. Sizes vary, and the internal content is heterogeneous, with visible inclusions in some structures.\nMorphological variability of structures. Some objects appear similar, but closer examination reveals marked variability. Consistent budding, typical for yeast forms, is not observed in most cases.\nStructure with a distinct wall and granular internal content. In some preparations, structures with a well-defined wall and pronounced internal content are observed.\nUnlike typical yeast forms, the central area here is heterogeneous and composed of multiple inclusions. This pattern may correspond to a developmental stage or sporulation and requires cautious interpretation. The presence of such internal organization further suggests that these objects should not be automatically classified as cryptococci based solely on the presence of a halo.\nClinical context Similar structures were identified in Danio rerio.\nThe process was systemic, involving parenchymal organs. Granulomatous inflammation was observed. Mycobacteriosis was excluded based on microscopy. In this context, the morphological findings are unlikely to be incidental. They integrate into the overall pattern of the disease, making a fungal origin plausible.\nInterpretation The combination of intratissue localization, granulomas, and round halo-containing structures does resemble cryptococcus-like lesions. However, key features required for a confident diagnosis of cryptococcosis are lacking. Most notably, there is no consistent budding, and the observed structures are morphologically heterogeneous. In addition, a halo is not a specific feature and may arise under various conditions, including osmotic effects and preparation artifacts.\nConclusion Round structures with a pronounced halo may resemble cryptococci, especially in the presence of granulomatous inflammation and internal organ involvement. Nevertheless, morphology in this case provides only a direction for interpretation and does not allow a definitive diagnosis.\nSuch findings require cautious evaluation within the full context of the process. ","permalink":"https://fossamethod.ru/en/posts/crypto/","summary":"Not everything with a capsule is Cryptococcus. Morphology may resemble it, but conclusions require caution.","title":"Cryptococcus-like structures in fish"},{"content":"\nFungal elements are regularly encountered in fish preparations.\nHowever, their presence alone does not allow a definitive conclusion about the nature of the process. In some cases, this represents surface colonization of damaged tissues; in others, an invasive process with spread into tissues and body cavities.\nThis page presents observations of fungal structures in fish and an approach to their interpretation.\nSaprolegnia and surface colonization The most well-known “fungal” lesions in fish are associated with Saprolegnia. In aquaculture and aquariums, this appears as a characteristic “cotton-like” growth on the body. In the vast majority of cases, Saprolegnia is not the cause but a consequence of tissue damage, necrosis, or stress (transport, aggression, environmental conditions).\nUnder normal conditions, the fish immune system effectively suppresses these organisms, despite the constant presence of spores in the water. When defenses are compromised, the organism begins to develop actively and forms superficial mycelial masses. This is why juveniles are affected more frequently: less developed immunity, smaller body size, and less time to compensate for damage.\nIt is important to note that Saprolegnia is not a “true fungus” but an oomycete. Nevertheless, morphologically it forms typical mycelial structures. Microbial communities Superficial mycelial growth rarely exists in isolation. Hyphae form a structure that harbors bacteria, ciliates, nematodes. In practice, this represents a complex microbial system rather than a purely fungal process.\nParasitic forms There are cases where fungal elements behave differently.\nUnlike Saprolegnia, hyphae do not form prominent tufts but spread along tissue surfaces, intertwine, and form dense слизистые structures. Such processes may be associated with involvement of internal organs.\nObservation Below is an example observed in juvenile salmonids.\nTypical findings:\ngills pale, light pink, internal organs pale, covered with transparent mucus, stomach and intestine filled with mucus, fungal spores present in contents and on organ surfaces. Such conditions are often accompanied by intestinal distension.\nImportant: bacterial gas production is typically postmortem, whereas similar changes in fungal processes may develop during life. Mucus in the body cavity. Organs within the body cavity are covered with mucus.\nSpores in mucus from internal organs. Spores are readily detected in the mucous content of internal organs.\nHemorrhages in muscle tissue. On transmitted light, hemorrhages can be observed in the abdominal region.\nMycelial structures in native preparation. Hyphae and structures associated with sporulation are detected in scrapings.\nThe picture becomes coherent:\nhyphae are localized in tissues and cavities, spores are present in mucus, changes are systemic. This allows morphological findings to be interpreted as a unified process.\nSpores. Löffler’s methylene blue (native). Spores. May–Grünwald stain. Spores. May–Grünwald stain. Staining may result in a reduction in spore size, which can complicate interpretation.\nTherefore, for primary detection, native preparations and water-based stains (e.g., Löffler) are preferable.\nFungal structures in fish may represent either secondary colonization or an independent pathological process. Their evaluation should be based not on the fact of detection, but on morphology, localization, and context. ","permalink":"https://fossamethod.ru/en/posts/fungi/","summary":"Hyphae in fish are not always saprolegniosis. It is important to distinguish colonization from invasive processes.","title":"Fungal structures in fish: colonization or invasive process"},{"content":"\nThe examined fish showed no visible signs of disease during life. Mortality occurred predominantly at night.\nGills were pale, and the fish were slightly emaciated. Necropsy revealed granulomas in the spleen and/or kidneys. Parenchymal organs were enlarged and anemic. The gross appearance was consistent with mycobacteriosis. However, Ziehl–Neelsen staining of impression smears from spleen and kidney did not reveal acid-fast bacteria. The granulomas were necrotic, a feature commonly associated with mycobacterial infections.\nHead kidney of Chromis viridis with large granulomas. Granulomas in the spleen of Chromis viridis. Clusters of organisms with basophilic horseshoe-like structures. Staining of impression smears using Gram and Romanowsky–Giemsa methods, combined with careful microscopy, revealed numerous small Gram-positive budding cells (1–3 µm) within histiocytes of the kidney and spleen. Larger cells showed structures resembling basophilic, horseshoe-shaped nuclei (Fig. 1–6).\nInclusions in a histiocyte in the spleen of Chrysiptera cyanea. Löffler methylene blue. Long black arrow — histiocyte; short gray arrows — organisms. Horseshoe-like structures in histiocytes of Chromis viridis spleen. Romanowsky–Giemsa stain. Horseshoe-like structures in histiocytes of Chrysiptera cyanea trunk kidney. Romanowsky–Giemsa stain. Budding cells in the spleen of Acanthurus leucosternon. Romanowsky–Giemsa stain. Inclusions in histiocytes of Acanthurus leucosternon spleen. Löffler methylene blue. The findings are consistent with a diffuse invasive mycosis caused by yeast-like organisms resembling Histoplasma. The formation of epithelioid-cell granulomas and necrotizing granulomatous inflammation is commonly described in H. capsulatum infections. No mycelial forms were observed in any of the samples. The extent of granulomatous inflammation in parenchymal organs suggests a chronic, slowly progressing disease.\nThis case highlights the presence of diseases with atypical etiology in aquarium systems and emphasizes the importance of thorough pathogen identification. Available literature mainly describes experimental infections of poikilothermic animals aimed at studying histoplasmosis under temperatures lower than typical for this pathogen (below 35°C)(\u0026ldquo;Experimental histoplasmosis in cold-blooded animals\u0026rdquo; DOI:10.1007/BF02063081).\n","permalink":"https://fossamethod.ru/en/posts/histoplasma-like/","summary":"\u003cbr\u003e\r\n\u003cp\u003eThe examined fish showed no visible signs of disease during life. Mortality occurred predominantly at night.\u003c/p\u003e\n\u003cbr\u003e\r\n\u003cp\u003eGills were pale, and the fish were slightly emaciated. Necropsy revealed granulomas in the spleen and/or kidneys. Parenchymal organs were enlarged and anemic. The gross appearance was consistent with mycobacteriosis. However, Ziehl–Neelsen staining of impression smears from spleen and kidney did not reveal acid-fast bacteria. The granulomas were necrotic, a feature commonly associated with mycobacterial infections.\u003c/p\u003e","title":"Granulomatous lesions in fish: a histoplasma-like case"},{"content":"\nGranulomatous lesions in fish should not be automatically attributed to mycobacteriosis.\nA similar gross presentation may reflect completely different etiologies, and microscopy is often decisive.\nThis page presents selected observations and morphological examples.\nEach card links to a separate page with a full analysis.\nHistoplasma-like structures\rSmall intracellular yeast-like cells (1–3 µm) within histiocytes of the spleen and kidney. Halo, budding, and horseshoe-like basophilic structures.\nOpen case\rCryptosporidium-like structures\rSmall uniform round structures with a distinct halo. Morphologically similar to cryptosporidia but require cautious interpretation.\nOpen case\rGoussia\rCoccidia with oval oocysts and elongated sporozoites inside sporocysts. A characteristic example of intestinal parasites in fish.\nOpen case\rIntracellular fungal forms\rLarge cells with multiple inclusions and tissue-associated forms potentially linked to fungal etiology.\nOpen case\rImportant\nIn pathology and microbiology, a granuloma is a non-specific response.\nIt indicates a chronic inflammatory process but does not identify the causative agent by itself.\nFAQ Are granulomas always caused by mycobacteria? No. Granulomas are a non-specific response with multiple possible causes.\nCan diagnosis be made by gross appearance? No. Similar lesions may have completely different origins.\nWhy is microscopy important? It reveals intracellular structures and helps differentiate processes.\nAre all parasite-like structures actually parasites? No. Morphology alone can be misleading.\nWhy avoid quick conclusions? Because identical patterns can arise from different mechanisms.\n","permalink":"https://fossamethod.ru/en/posts/intracellular/","summary":"Intracellular microorganisms in fish: morphology, localization, and diagnostic interpretation.","title":"Granulomas and intracellular agents in fish"},{"content":"\nDepth of analysis F. F.O. F.O.S. Toggle Myth / Reality\rFin rot is a common bacterial disease Fin rot is one of the most common diseases of aquarium fish. Sooner or later, almost every aquarist encounters this problem.\nThe disease is usually easy to recognize, even without specialized equipment. Its main sign is the deterioration of the fins. At first, the fin edges become uneven and frayed, then gradually begin to recede. Sometimes the edges turn white or cloudy, and in severe cases, redness may appear at the base of the fins.\nFin rot is thought to be caused by bacteria that proliferate in the aquarium under unfavorable conditions. The disease is most often associated with polluted water, infrequent water changes, overfeeding, overcrowding, or severe stress in fish.\nA weakened fish loses its immune defenses, allowing bacteria to begin destroying fin tissue. Without intervention, the process can spread, causing extensive fin damage or even the death of the fish.\nExperienced aquarists can usually identify fin rot by appearance alone, based on the characteristic look of damaged fins. In such cases, it is important not to delay treatment.\nAntibacterial medications are commonly used for treatment. Methylene blue, malachite green, various combination products for bacterial infections, and antibiotics are considered effective. Salt baths or an increase in water temperature are sometimes used as well.\nImproving husbandry conditions is also recommended: changing the water, removing uneaten food, checking filtration, and reducing the stocking density.\nIf treatment begins early, the fins usually regenerate gradually, and the disease can be stopped before it progresses.\nfanfishka.ru tropica.ru Fin rot: what exactly is being damaged? When we see a fish with frayed, shortened, or whitish fin edges, we often immediately use the familiar term “fin rot.” The explanation follows: “bacteria are eating away the fins,” and then comes the suggestion to treat the fish with antibacterial medications.\nThe problem is that fin deterioration is an observed change, whereas bacterial infection is only one possible explanation for it. The appearance of a fin edge alone cannot tell us the sequence of events: what was damaged first, why it happened, or what role microorganisms played.\nA fin can deteriorate because of infection, injury, or noninfectious pathological processes. The same outward appearance does not necessarily mean the same cause.\n“Rot” and “erosion”: why terminology matters In aquarium keeping, “fin rot” often refers to almost any shortening or deterioration of the fins. But the term itself already points toward an infectious explanation.\nScientific literature also uses the term fin erosion. Sharples and Evans (1996) used it to describe a particular pathological process in which no substantial microbial involvement was detected, and proposed distinguishing this form of damage from infectious fin rot.\nHowever, we cannot simply relabel every frayed fin as fin erosion and consider its cause established. Erosion describes tissue damage; its mechanism and etiology must be examined separately. Even bacterial columnaris disease can be accompanied by fin erosion (Declercq et al., 2013).\nHow a fin ray is structured Structure of fin rays. A — segmented lepidotrichia. B — transverse section of a lepidotrichium showing its two hemisegments. The fins of bony fish are supported by lepidotrichia — segmented fin rays of dermal origin. These are not solid bony rods. Each ray consists of two curved hemisegments, with successive segments connected by ligaments along the ray. Blood vessels, nerves, and connective tissue lie between the two halves. Adjacent rays are also interconnected, and the entire structure is surrounded by the soft tissues of the fin (Sharples \u0026amp; Evans, 1996).\nThis structure matters when interpreting damage: a loss of connections between its components may appear as splitting, fraying, or fragmentation of a fin ray. That appearance alone does not explain why those connections failed.\nWhat does the experiment under the stereomicroscope show? Ваш браузер не поддерживает видео. Fin ray separation under a stereomicroscope In the video, a dissecting needle is applied to a damaged fin ray. Its segmented components separate, while identifiable soft tissues remain in the area being examined.\nWhat did we observe? Certain components of a fin ray can separate at their junctions when mechanical force is applied.\nWhat did we not establish? Why those components had already become weakened or damaged before examination. Possible explanations include a previous injury, changes in the soft tissues, or another pathological process. Answering that question requires information about the fish\u0026rsquo;s condition, its environment, and the lesion itself.\nThe video demonstrates how components of a fin ray separate when a needle is applied. It is not an experiment that rules out a bacterial cause of the lesion in the living fish.\nCan a fin deteriorate without a bacterial infection? Yes. And this is more than a theoretical possibility.\nSharples and Evans (1996) investigated fin erosion in goldfish (Carassius auratus) living in a section of river exposed to effluent from a pulp and paper mill. Histological examination revealed a sequence of tissue changes.\nThe outer structures of the epidermis were affected first: the cuticle and the surface microridges of epithelial cells were lost, followed by epithelial cell damage and sloughing. As the process progressed, edema and changes in the dermis developed, followed later by damage to the lepidotrichia. Clear bacterial involvement was rarely observed in the examined samples and was considered likely to be secondary (Sharples \u0026amp; Evans, 1996).\nThis is a particularly important example: a fin can become shorter and deteriorate without an established primary bacterial infection. The authors did not, however, claim to have identified a universal cause of all such lesions in fish.\nWhat about nutrition, metabolism, and tissue trophism? These possibilities should not be dismissed either. Nutrition, mineral metabolism, and the physiological condition of a fish influence tissue integrity and repair. Fins depend not only on the rigid components of their rays, but also on the epithelium, connective tissue, blood vessels, and mechanical connections between these structures.\nHere, however, we must distinguish a reasonable working hypothesis from an established mechanism in a particular lesion. For example, nutritional or metabolic disturbances, or chronic systemic disease, may affect tissue condition and repair. But fin erosion alone does not prove that impaired tissue nutrition caused it.\nIn particular, the explanation that “distal portions of the fins deteriorate first because they have the lowest priority for blood supply” requires direct physiological and morphological evidence. General studies of mineral metabolism in fish do not demonstrate that this sequence applies to every case of fin deterioration (Lall \u0026amp; Kaushik, 2021).\nThus, impaired tissue trophism is a possible line of investigation, not an automatic alternative to bacterial infection.\nWhen bacteria really can be the cause Bacteria encountered in infectious fin deterioration. Left — filamentous forms; right — small rod-shaped bacteria. We should also avoid the opposite mistake: assuming that every bacterial infection is secondary.\nA good example is columnaris disease, caused by bacteria of the Flavobacterium columnare group (taking into account recent taxonomic changes within this complex). Lesions of the skin, gills, and fins, including fin erosion, have been described in this disease (Declercq et al., 2013).\nBut another sequence of events is also possible: the tissue is damaged first, and bacteria subsequently colonize its altered surface. Fish are constantly in contact with microorganisms. Their skin and mucus contribute to immune defense while also interacting with the normal microbiota (Gomez et al., 2013); (Reverter et al., 2018).\nTherefore, finding bacteria on a damaged fin is meaningful, but it is not enough to answer the question “what initiated the damage?” The type of bacteria, the nature of the lesion, their association with tissue changes, and, where possible, the progression of the process all matter.\nHow to investigate an individual case Rather than starting with the name of a medication, it is more useful to work through a series of questions.\nWhat has changed? Are only the tips affected, individual rays, or the entire fin membrane? Is there inflammation, hemorrhage, necrosis, mucus, deposits, or damage to the body and gills? How did the process develop? Did the lesions appear within hours or develop over weeks? Are there signs of injury, aggression from tankmates, or contact with equipment? Which fish are affected? One individual, a particular species, or several species sharing the same system? Have water parameters or husbandry conditions changed recently? What does microscopy show? Which structures remain intact, which are damaged, are microorganisms associated with the lesion, and is there a cellular response? What else needs to be confirmed? When bacterial infection is suspected, targeted sampling, bacterial culture, molecular methods, or histology may be needed. The choice depends on the question being asked and the methods available. Microscopy helps clarify the nature of the damage, but it cannot always establish its etiology on its own. At the same time, being unable to perform culture or PCR immediately is no reason to abandon observation, description of the lesions, or examination of environmental conditions.\nA diagnosis should explain fin damage, not merely restate its appearance in different words.\nConclusion “Fin rot” is a convenient term in everyday conversation, but it is too often used as a ready-made diagnosis. Similar outward changes may result from different processes: injury, noninfectious erosion, primary bacterial infection, or secondary colonization of damaged tissues by microorganisms.\nThe lepidotrichia video shows how a tissue structure assembled from separate components can split apart. Studies of noninfectious erosion demonstrate that fin deterioration does not necessarily require bacterial involvement. And research on columnaris disease reminds us that bacterial damage is also a real possibility.\nThe key is not to choose a cause based on a familiar name. First describe what is happening, then investigate the possible mechanisms, and only then decide what to treat and how.\nReferences Sharples, A. D., Evans, C. W. (1996). Pathology of fin erosion in goldfish Carassius auratus. Diseases of Aquatic Organisms, 24, 81–91. https://doi.org/10.3354/dao024081 Declercq, A. M., Haesebrouck, F., Van den Broeck, W., Bossier, P., Decostere, A. (2013). Columnaris disease in fish: a review with emphasis on bacterium-host interactions. Veterinary Research, 44, 27. https://doi.org/10.1186/1297-9716-44-27 Gomez, D., Sunyer, J. O., Salinas, I. (2013). The mucosal immune system of fish: the evolution of tolerating commensals while fighting pathogens. Fish \u0026amp; Shellfish Immunology, 35, 1729–1739. https://doi.org/10.1016/j.fsi.2013.09.032 Lall, S. P., Kaushik, S. J. (2021). Nutrition and metabolism of minerals in fish. Animals, 11, 2711. https://doi.org/10.3390/ani11092711 Reverter, M., Tapissier-Bontemps, N., Lecchini, D., Banaigs, B., Sasal, P. (2018). Biological and ecological roles of external fish mucus: a review. Fishes, 3, 41. https://doi.org/10.3390/fishes3040041 Questions and Answers Is fin deterioration always bacterial fin rot? No. Similar outward changes can occur with noninfectious erosion, injuries, and bacterial diseases.\nWhy do fins become frayed? The epithelium, connective tissue, and connections between fin ray segments can all be damaged. Different mechanisms can produce a similar outward appearance.\nCan the dissecting-needle video reveal the cause? No. The video shows how the ray components separate under mechanical force. The cause of the pre-existing damage must be investigated separately.\nShould antibiotics be used immediately? No. The nature of the lesion, husbandry conditions, and reasons to suspect bacterial infection should be assessed first. Treatment depends on the suspected or confirmed underlying process.\nHow can microscopy help? It allows us to assess the tissues and detect potential microorganisms. But their presence on the surface of a lesion does not always prove that they initiated the pathological process.\n","permalink":"https://fossamethod.ru/en/posts/finerosion/","summary":"Why a damaged fin does not necessarily mean bacterial fin rot. A video showing lepidotrichial separation, research on noninfectious fin erosion, and evidence of primary bacterial lesions.","title":"Fin Rot"},{"content":"\rToggle Myth / Reality\rEverything about hexamitids has been clear for a long time — there is nothing to investigate here. hexamitids\rAlmost all cichlids (and not only cichlids) always have hexamitids. These are normal internal parasites, part of the intestinal microflora. They live inside the fish permanently and usually cause no problems. Many fish live with them for years, so clearly there is nothing dangerous about it.\nWhich exact hexamitids they are does not really matter. Hexamita, Spironucleus, Cryptobia — essentially the same thing under different names. They cause the same problems and are treated in the same way, so there is no point in dealing with taxonomy. For aquarists, the result matters, not the Latin genus.\nProblems start under stress: water changes, temperature drops, relocation, aggression, spawning, or simply weakened immunity. At this point hexamitids become active and hexamitosis begins. The parasites were living quietly inside the fish before, and then they suddenly get out of control.\nDiagnosis is easy and does not require any special tests. If a fish produces white or transparent feces, loses weight, darkens, and refuses food — this is almost always hexamitosis. These signs have been known for a long time and confirmed by practice; there is no need for a microscope. Scrapes and smears only create unnecessary stress and make things worse.\nTreatment is also well known. The main drug is metronidazole. It has been used for decades, sometimes combined with increased temperature, salt, or stronger aeration. If it does not work, the dose is increased or the course is repeated. Some people mix metronidazole into food, others add it to water — there is no fundamental difference.\nIt is impossible to completely eliminate hexamitids. Even after treatment, parasites remain inside the fish and are only temporarily suppressed. Therefore, treatment is about control, not eradication. The key is to notice symptoms early and not let the process progress.\nHexamitids are often said to be introduced with new fish, but this is not necessarily true. They are already present in the fish. Poor conditions simply trigger their activation. That is why prevention is mainly about good water quality and low stress, not quarantine and isolation.\nOverall, hexamitosis is not really a disease but an indicator of poor husbandry. Improve conditions, treat with metronidazole — and everything returns to normal.\nfanfishka.ru — “Hexamitosis in cichlids”\nFish do not need hexamitids Ваш браузер не поддерживает видео. hexamitids Intestinal flagellates of the genera Hexamita and Spironucleus are not an obligatory component of fish physiology.\nTheir absence does not impair digestion, growth, or survival, which clearly distinguishes them from true symbionts\n(Dyková \u0026amp; Lom, 1981; Paperna, 1996).\nExperience from aquaculture and public aquaria shows that fish populations free of intestinal flagellates:\nexhibit more stable growth; have lower juvenile mortality; suffer less frequently from chronic wasting\n(Cruz-Lacierda \u0026amp; Subasinghe, 1998). Asymmetry of the host–parasite relationship The relationship between fish and hexamitids is asymmetric:\nfish can exist without the parasite; the parasite cannot exist without the host. This is a fundamental principle of parasitology, applicable to most aquarium parasites\n(Paperna, 1996; Burreson et al., 2006).\nTherefore, the absence of hexamitids represents a normal and stable condition, not an artificial or “sterile” state.\nWhy the myth of “normal intestinal microflora” emerges The idea of hexamitids as a normal component of intestinal microflora arises from conceptual confusion:\nMicrobiota ≠ protozoan parasites\nConcepts related to bacterial microbiota are incorrectly transferred to eukaryotic parasites\n(Llewellyn et al., 2014).\nSubclinical presence\nLow parasite abundance may not cause obvious clinical signs, but this does not make it physiologically normal\n(Kent et al., 2004).\nLack of diagnostics\nIn many systems, the presence of hexamitids is never verified microscopically, and conclusions are based solely on nonspecific signs.\nWhite feces is not a diagnosis White or translucent feces are not specific for hexamitid infection.\nSuch signs may occur in cases of:\nstarvation; bacterial enteritis; intestinal inflammation of other etiologies; intoxication; liver and pancreatic dysfunction\n(Kent et al., 2004). Without microscopic confirmation, the etiological agent cannot be reliably identified.\nWhy outbreaks actually occur Hexamitids do not “activate” spontaneously.\nPopulation expansion is linked to specific epizootiological factors:\nintroduction with new fish; high stocking density; chronic stress; nutritional imbalance; impairment of intestinal barrier function\n(Cruz-Lacierda \u0026amp; Subasinghe, 1998; Tort et al., 2016). In this framework, stress is a modifying factor, not the source of the parasite.\nKey implication Hexamitids are neither an obligatory nor a desirable component of aquarium systems.\nTheir presence should be regarded as a risk factor, not as physiological norm.\nFish do not need hexamitids.\nHexamitids need fish.\nReferences Dyková, I., Lom, J., 1981. Hexamita salmonis and related flagellates of fish. Folia Parasitologica 28, 153–166. Paperna, I., 1996. Parasites, infections and diseases of fishes in Africa: An update. FAO, Rome. Cruz-Lacierda, E.R., Subasinghe, R.P., 1998. Occurrence and control of intestinal flagellates in freshwater fish culture. Aquaculture Research 29, 697–703. Kent, M.L., et al., 2004. Diagnostic procedures for diseases of fish and shellfish. American Fisheries Society, Bethesda. Llewellyn, M.S., Boutin, S., Hoseinifar, S.H., Derome, N., 2014. Teleost microbiomes: the state of the art. Frontiers in Microbiology 5, 207. Tort, L., Balasch, J.C., Mackenzie, S., 2016. Fish immune system: a crossroads between innate and adaptive responses. Fish \u0026amp; Shellfish Immunology 53, 1–12. Burreson, E.M., et al., 2006. Parasites and diseases of marine organisms. Springer. FAQ Does white feces always mean hexamitids?\nNo. It is a common but non-specific sign and may indicate various conditions.\nAre hexamitids always present in fish?\nNo. They are not a normal component of fish physiology and appear after introduction.\nWhy does a fish lose weight while still eating?\nBecause intestinal function may be impaired, preventing proper nutrient absorption.\nCan metronidazole be used “just in case”?\nNo. Treatment without confirmation is guesswork and may be ineffective.\nIs stress the main cause of outbreaks?\nNo. Stress may worsen the condition but does not create parasites.\n","permalink":"https://fossamethod.ru/en/posts/hexa/","summary":"Fish do not need hexamitids. Parasites need fish. Why outbreaks are linked to introduction and imbalance rather than \u0026lsquo;activation\u0026rsquo;.","title":"Hexamitids Without Myths"},{"content":"\nToggle Myth / Reality\rIchthyophthirius is present in every aquarium.\nThis parasite is believed to be permanently present in the system and becomes active only when environmental conditions deteriorate. Stress, temperature drops, water changes, or conflicts between fish are thought to activate a parasite that had previously remained in a dormant state.\nIt is widely accepted that Ichthyophthirius forms highly resistant cysts capable of persisting for long periods in substrate, filters, and decorations. Even after prolonged absence of clinical signs, the infection is assumed not to disappear but merely enter a latent phase.\nIt is often stated that the disease does not necessarily need to be introduced from outside. Instead, it supposedly arises spontaneously when water quality deteriorates, fish are overfed, or maintenance is inadequate. According to this view, stress alone is sufficient to cause the parasite to appear.\nTap water is sometimes described as containing “free-floating cysts”. As a result, any water change is considered a potential source of infection, regardless of water origin or treatment.\nTreatment is believed not to eliminate the parasite completely. Medications are said to suppress symptoms only temporarily, while the parasite remains in the system and inevitably reappears under unfavorable conditions.\nfanfishka.ru ekzotika.com Why the term “cyst” misleads aquarists Ваш браузер не поддерживает видео. Division of Ichthyophthirius In classical literature, the dividing stage of Ichthyophthirius multifiliis is described as an encysted tomont (Dickerson and Clark, 1996; Matthews, 2005).\nI. multifiliis indeed has a cyst-like stage (encysted tomont), but it belongs to the category of reproductive cysts. Unlike cryptobiotic resting cysts of many protozoa, this envelope is thin, temporary, and designed for palintomic division rather than long-term persistence in the external environment.\nPersistence is the ability of a microorganism (virus, bacterium, fungus) or a chemical agent to retain viability or structural integrity outside the host for extended periods.\nIn classical protozoology, the word cyst is used more broadly than the concept of a “highly resistant resting cyst” typical of amoebae. Historically, encystment means “formation of a cellular envelope — regardless of its thickness, function, or degree of resistance” (Corliss, 2001; Kudo, 1954). Thus, in parasitological tradition:\na cyst ≠ necessarily a resting stage a cyst ≠ necessarily thick-walled a cyst = a cell enclosed by a wall Accordingly, the term is used correctly within its scientific context.\nCyst type Example organisms Primary function Wall structure Metabolic activity Environmental resistance Cryptobiotic (resting) Amoebae, colpodids Survival under adverse conditions, dispersal Thick, multilayered, dense Sharply reduced (cryptobiosis) High, long-term persistence Spore / persistent Myxosporeans, apicomplexans (spores) Transmission between hosts Specialized, robust Minimal Very high Reproductive (palintomic) Ichthyophthirius multifiliis (tomont), some apostomes Rapid multiple division Thin, temporary, fragile High, active division Low, short-lived Correct statement: Ichthyophthirius forms a thin-walled, unstable reproductive cyst.\nThe myth of “ubiquitous” Ichthyophthirius Ichthyophthirius\rHistorical note\nFor centuries, it was believed that living organisms could arise from non-living matter — for example, larvae from decaying meat or microorganisms from water and mud. Experiments by Francesco Redi (1668) and later by Louis Pasteur (1859) conclusively disproved this idea. A fundamental biological principle was established: life arises only from pre-existing life (omne vivum ex vivo). This principle underlies modern microbiology, parasitology, and epizootiology.\nOnce the life cycle is understood, it becomes clear that I. multifiliis cannot “wait” in an aquarium for years. The parasite lacks a long-term dormant stage capable of surviving adverse conditions or prolonged absence of a host. Therefore, it cannot persist indefinitely in a system without continuous transmission between fish.\nWhy the parasite cannot simply remain dormant:\nThe trophont feeds and grows within host tissues; The tomont actively divides; The theront actively seeks a host and rapidly dies without one. None of these stages are adapted for long-term survival without metabolic activity.\nIf susceptible fish are absent, the parasite’s life cycle terminates naturally.\nTherefore:\nThe parasite cannot persist in substrate for years without a host; It cannot “awaken” after prolonged dormancy; It does not arise spontaneously due to deteriorating conditions. Stress may exacerbate an existing infection but cannot create a parasite from nothing (see historical note above).\nWhy the myth appears convincing\nThe subjective impression that “it was always there” arises from common epizootiological errors:\nSubclinical carriage: fish may harbor low parasite loads without visible symptoms. Stress or environmental change allows rapid population growth, creating the illusion of sudden appearance. Incomplete treatment: premature termination of therapy allows residual parasites to persist and later cause relapse. Repeated micro-introductions: parasites may enter via new fish, water from other aquaria, plants, equipment, or even hands after contact with infected systems. Diagnostic errors: different skin and gill conditions may be mistaken for “ich”, making unrelated problems appear as recurring infection. Tap water and “floating cysts”\nClaims that Ichthyophthirius is constantly present in tap water are inconsistent with its biology:\nInfective stages require a living host within a limited time window (Farley and Heckmann, 1980; Matthews, 2005); Active stages poorly tolerate prolonged absence of fish (Post, 1987); Standard water treatment processes are highly unfavorable for parasite survival (Lahnsteiner and Weismann, 2007). In practice, reports of “cysts in tap water” most often result from misidentification of free-living ciliates or sample contamination.\nKey implication Ichthyophthirius is not an obligatory component of every aquarium.\nIf detected, it has been introduced and continues to circulate between fish. Infection control is therefore based not on fighting mythical “dormant forms”, but on:\nQuarantine of new fish; Epizootiological control of the system; Correct and complete therapy; Prevention of cross-contamination between aquaria. References Corliss, J.O., 2001. Protozoan Cysts and Spores, in: Encyclopedia of Life Sciences. John Wiley \u0026amp; Sons, Ltd. https://doi.org/10.1038/npg.els.0001934 Dickerson, H., Clark, T., 1996. Immune response of fishes to ciliates. Annual Review of Fish Diseases 6, 107–120. https://doi.org/10.1016/S0959-8030(96)90008-3 Farley, D.G., Heckmann, R., 1980. Attempts to control Ichthyophthirius multifiliis Fouquet by chemotherapy and electrotherapy. Journal of Fish Diseases 3, 203–212. https://doi.org/10.1111/j.1365-2761.1980.tb00444.x Kudo, R.R., 1954. Protozoology, 4th ed. Springfield, Illinois. Lahnsteiner, F., Weismann, T., 2007. Treatment of ichthyophthiriosis in rainbow trout and common carp. Journal of Aquatic Animal Health 19, 186–194. https://doi.org/10.1577/H07-002.1 Matthews, R.A., 2005. Ichthyophthirius multifiliis and ichthyophthiriosis in freshwater teleosts. Advances in Parasitology 59, 159–241. https://doi.org/10.1016/S0065-308X(05)59003-1 Post, G., 1987. Textbook of Fish Health. FAQ Is Ichthyophthirius present in every aquarium?\nNo. It appears only after introduction.\nDo white spots always mean ich?\nNo. Similar signs may be caused by other conditions.\nCan tap water introduce ich?\nHighly unlikely. The main route is infected fish or equipment.\nWhy does the disease return after treatment?\nUsually due to reinfection or incomplete treatment, not persistence.\nIs the cyst a dormant stage?\nNo. It is a reproductive stage, not long-term survival.\n","permalink":"https://fossamethod.ru/en/posts/ichthyophthirius/","summary":"\u003cbr\u003e\r\n\r\n\r\n  \r\n  \r\n  \r\n  \r\n\r\n  \r\n  \r\n  \r\n    \r\n  \r\n\r\n  \r\n\r\n  \u003cdiv id=\"CryptBlok\" class=\"toggleblock myth-reality\"\u003e\r\n    \u003cbutton class=\"toggle-btn\" onclick=\"toggleBlock('CryptBlok')\"\u003eToggle Myth / Reality\u003c/button\u003e\r\n    \u003cdiv class=\"toggle-content first\"\u003e\u003chr\u003e\n\u003cp\u003e\u003cstrong\u003eIchthyophthirius is present in every aquarium.\u003c/strong\u003e\u003cbr\u003e\nThis parasite is believed to be permanently present in the system and becomes active only when environmental conditions deteriorate. Stress, temperature drops, water changes, or conflicts between fish are thought to activate a parasite that had previously remained in a dormant state.\u003c/p\u003e\n\u003cp\u003eIt is widely accepted that \u003cem\u003eIchthyophthirius\u003c/em\u003e forms highly resistant cysts capable of persisting for long periods in substrate, filters, and decorations. Even after prolonged absence of clinical signs, the infection is assumed not to disappear but merely enter a latent phase.\u003c/p\u003e","title":"Ichthyophthiriosis Without Myths"},{"content":"\rIntroduction Fish are not a single organism and not a single type of “patient,” but a vast group of vertebrate animals comprising more than 34,000 species. For comparison, humans represent just one species — Homo sapiens. Fish, in contrast, encompass thousands of life forms with diverse anatomy, physiology, and survival strategies.\nDespite this enormous diversity, most fish share a fundamental physiological adaptation to life in an aquatic environment. Their skin, mucous layer, respiratory system, and behavior have evolved to function in water rather than in contact with dry surfaces and rough objects. Some species actively interact with substrate, rocks, or sediment — for example, benthic fish that burrow into sand — and their integument is adapted to mechanical exposure. However, even such species remain sensitive to improper handling outside their natural environment.\nFish are constantly in contact with vast numbers of microorganisms. Water is not a sterile medium, and the skin together with the mucus forms an active protective barrier. The mucous layer contains antimicrobial compounds and immune cells that maintain a stable equilibrium between the host organism and the surrounding microflora. Therefore, the mere presence of bacteria on the skin or gills does not indicate disease — pathology begins when the barrier is disrupted or when the general condition of the organism deteriorates.\nAmong aquarists, a widespread belief persists that serious diagnostics inevitably end in the death of the fish. This is not true. Most primary diagnostic procedures — external examination, assessment of skin and fin condition, collection of scrapes and smears, and examination of gill mucus — are non-lethal manipulations that, when performed correctly, do not pose a threat to the patient’s life. Moreover, early diagnosis often helps prevent severe conditions that would otherwise require radical intervention.\nIn my practice, I follow a simple rule — if I need something, chances are someone else has needed it before, and a solution may already exist. It’s worth searching and verifying. Seven billion people live on this planet — don’t forget that.\nHere are examples of peer-reviewed scientific publications on non-lethal manipulations in fish:\n“Assessing the suitability of a non-lethal biopsy punch for sampling fish muscle tissue” — muscle biopsy using a 4 mm punch; healed wounds documented (Henderson et al., 2016). “Best practices for non-lethal blood sampling of fish via the caudal vasculature” — methods for collecting blood from the caudal peduncle; illustrated examples provided (Lawrence et al., 2020). “Nonlethal clinical techniques used in the diagnosis of diseases of fish” — cover-slip skin scrapes, buffered bacterial culture; includes distal gill filament and fin-edge sampling (personally not preferred). Fish survived (Smith, 2002). “Non-Lethal Sampling Supports Integrative Movement Research in Freshwater Fish” — review article on various non-lethal sampling techniques, mainly molecular approaches (Thorstensen et al., 2022). “Skin swabbing protocol to collect DNA samples from small-bodied fish species” — comparison of fish behavior and gene expression after fin clipping versus skin swabbing (Tilley et al., 2024). In general, these procedures are methodologically straightforward but require careful handling and an understanding of anatomy, and they do not require complex or expensive equipment when basic training is present. Scientific practice demonstrates that sampling is feasible. In the hobbyist world, stereotypes and fear of manipulation often remain the main obstacles.\nWhat to do with the fish after arrival. – A step-by-step visual guide for acclimation and initial procedures. Surgical operations on aquatic animals. – A resource demonstrating that complex veterinary interventions are possible and survivable for aquatic species. Presentation: In vivo diagnostics of fish in aquarium conditions: health monitoring and modern methods. – An overview of contemporary approaches to health assessment and parasite screening in captive fish. The fundamental principle of any work with fish is minimizing trauma and stress. Even simple use of medical gloves matters: they protect the mucous layer from damage, prevent the transfer of chemicals from human skin, and reduce the risk of introducing opportunistic microflora into compromised tissues. Non-lethal diagnostic methods are not “exotic veterinary medicine,” but standard practice available to anyone who approaches the patient with care, anatomical understanding, and willingness to work regardless of size.\nWhy Fish Do Not Die From Diagnostics — and Why They Sometimes Die After It One of the most persistent myths in aquaristics is the belief that diagnostics themselves are dangerous and may lead to fish mortality. This assumption often arises when a weakened patient dies shortly after examination or sampling. However, in most cases, such events represent temporal coincidence rather than a causal relationship.\nCompensatory Capacity of Fish Fish are evolutionarily adapted to constant interaction with an environment rich in microorganisms and mechanical exposure. Their skin and mucous layer form an active defense system containing antimicrobial compounds and immune cells. The gills possess an enormous contact surface with water and are continuously exposed to particles, microflora, and fluctuating hydrochemical conditions.\nIn natural habitats, fish regularly sustain micro-injuries through contact with substrate, food, other organisms, and environmental structures. Therefore, minimally invasive diagnostic procedures — such as external inspection, skin scrapes, smears, or examination of gill mucus — are comparable in impact to routine environmental exposures that healthy organisms can tolerate without life-threatening consequences.\nWhen Death Coincides With Manipulation Sometimes a fish does die shortly after an examination. This creates the illusion that the procedure itself was the cause. In reality, these cases usually involve patients already in a state of profound physiological decompensation.\nDecompensation refers to the failure or exhaustion of adaptive mechanisms, where an organ or physiological system can no longer cope with stress or functional demand, leading to rapid deterioration. It is characterized by the rapid progression of symptoms and may require urgent medical intervention. Common causes include chronic disease, stress, exhaustion, or intoxication.\nWhen systemic dysfunction is advanced, compensatory mechanisms are already depleted. In such conditions, even minimal stress — removal from water, changes in hydrostatic pressure, brief hypoxia, or excitation — may act as a trigger for final collapse. The manipulation does not cause disease or pathology; it merely coincides with the terminal stage of an ongoing process.\nClinical Signs of Terminal Condition Practical experience shows that fish dying during minimal interventions often already exhibit severe systemic disorders.\nOne characteristic sign is intestinal atony with loss of sphincter control. In severe metabolic or inflammatory conditions, intestinal tone is lost, and any change in body position or fluid pressure may lead to passive discharge of intestinal contents. This is not a reaction to examination but an indicator of profound physiological failure.\nAtony is a pathological condition characterized by a marked decrease or complete loss of muscle tone in internal organs (commonly intestines or stomach) or skeletal muscles, resulting in impaired function.\nAnother frequent scenario involves severe metabolic disturbances, including fatty infiltration of internal organs. In such cases, hemodynamic reserve is reduced, and the vascular system loses the capacity to compensate for stress or pressure changes. These fish tolerate handling poorly not because of the procedure itself but due to advanced systemic pathology.\nAdditional signs commonly observed include:\ngeneralized muscular weakness and loss of coordination; severe respiratory dysfunction; cachexia or, conversely, extreme metabolic overload; chronic inflammatory conditions affecting internal organs. In all these situations, death following manipulation is a consequence of the patient’s underlying condition rather than the diagnostic intervention.\nConclusion If a fish dies after a brief examination or minimally invasive diagnostic procedure, this most often reflects an extremely compromised physiological state. The manipulation acts not as the cause of disease but as the final stressor accelerating an already progressing pathological process.\nRefusing diagnostics does not make treatment safer. On the contrary, early examination and timely detection of problems allow intervention before decompensation occurs — when the organism still retains the capacity for recovery. References Henderson, C.J., Stevens, T.F., Lee, S.Y., 2016. Assessing the suitability of a non-lethal biopsy punch for sampling fish muscle tissue. Fish Physiol Biochem 42, 1521–1526. https://doi.org/10.1007/s10695-016-0237-z Lawrence, M.J., Raby, G.D., Teffer, A.K., Jeffries, K.M., Danylchuk, A.J., Eliason, E.J., Hasler, C.T., Clark, T.D., Cooke, S.J., 2020. Best practices for non-lethal blood sampling of fish via the caudal vasculature. Journal of Fish Biology 97, 4–15. https://doi.org/10.1111/jfb.14339 Smith, S.A., 2002. Nonlethal clinical techniques used in the diagnosis of diseases of fish. J Am Vet Med Assoc 220, 1203–1206, 1162. https://doi.org/10.2460/javma.2002.220.1203 Thorstensen, M.J., Vandervelde, C.A., Bugg, W.S., Michaleski, S., Vo, L., Mackey, T.E., Lawrence, M.J., Jeffries, K.M., 2022. Non-Lethal Sampling Supports Integrative Movement Research in Freshwater Fish. Front. Genet. 13. https://doi.org/10.3389/fgene.2022.795355 Tilley, C., Barber, I., Norton, W., 2024. Skin swabbing protocol to collect DNA samples from small-bodied fish species. F1000Res 10, 1064. https://doi.org/10.12688/f1000research.73115.2 FAQ Can a fish die from a skin scrape?\nNo, if performed correctly.\nWhy do fish die after examination?\nThey were already in a critical state.\nShould diagnostic procedures be avoided?\nNo. Lack of diagnosis is often more dangerous.\nCan small fish be examined?\nYes. Size is not a limitation.\nWhat is more important: not touching or diagnosing?\nDiagnosis is essential for correct decisions.\n","permalink":"https://fossamethod.ru/en/posts/size/","summary":"Non-lethal fish diagnostics explained: why scrapes, smears and examinations are safe — and why severely compromised fish may die after handling.","title":"Patient Size Doesn’t Matter — Why Fish Don’t Die From Diagnostics"},{"content":"\rIf fish are dying in the aquarium for unknown reasons: Transfer all fish to another tank. Investigate what is happening. Mass mortalities can vary:\nDifferent species are dying simultaneously.\nDifferent genera and families have distinct lifestyles, physiology, and immune responses. If multiple species die at once, the cause is more likely water chemistry rather than a pathogen.\nOne species dies quickly and massively.\nThis is also often related to water chemistry — the most sensitive species reacts first.\nOne species dies periodically, over time.\nIn this case, infections or parasites are more likely, especially if this species has lower resistance (e.g., ciliates, bacteria).\nIf several fish have died in the same tank (a mass mortality event): During a mass mortality event, several fish should be examined at the same time. This helps determine which changes are consistent and which occur only in individual fish. Gills of fish that died at approximately the same time. The same changes were not present in every fish, so an isolated finding should not immediately be declared the cause of the mass mortality. Examine several fish at once for comparison and to distinguish common changes from individual pathology. During a mass mortality event, dead fish should ideally be grouped by the time they were found, and that time should be recorded. This makes it possible to compare early and late cases and reconstruct the sequence of events more accurately.\nView the neon tetra liver slide in the virtual microscope\rA fish’s appetite is not an indicator of health Fish have very strong instincts. Even if a fish eats, it does not mean it is healthy.\nThe intestine may be non-functional (smooth, transparent, like a water-filled bag).\nSuch a fish eats but dies of starvation: the stomach and intestine contain no food fragments.\nIt is possible the fish vomits after feeding — but this often goes unnoticed.\nDo not rely on appetite as a criterion of health.\nIf transferring fish from “dirty” water to clean water: Treat them for bacterial infections. Otherwise, the disease is likely to manifest later.\nIf the fish has been exposed to Cryptocarion irritans: Take regular scrapes and washes from the gills (at least once a month).\nThe gill form is invisible on the body… until it is too late.\rCryptocaryon irritans: Not Just White Spots\rCryptocaryon irritans. is a ciliated protozoan parasite, often visible to the naked eye. Tangs, butterflyfish, and boxfish are particularly …\rFish can be handled and treated directly Fish should not be injured unnecessarily. However, this does not mean that they cannot be restrained, examined, or treated by hand.\nBrief restraint with wet hands in examination gloves is a routine practical procedure. It allows the operator to collect a skin scrape, treat a wound, remove necrotic tissue, fungal growth, external parasites, or excessive pathologically altered mucus.\nIf a parasite or affected material is located on the body surface and is mechanically accessible, direct removal should at least be considered. Even incomplete cleaning can substantially reduce the burden on the fish within a few minutes.\nInfected mucus, deteriorating epithelium, or necrotic tissue should not be preserved merely because the mucus layer normally performs a protective function. In a particular case, this material may already contain large numbers of parasites, bacteria, and tissue debris.\nThe restriction should apply not to touching the fish itself, but to handling it incorrectly.\nIf an external parasite can be removed, remove it There is no need to wait for a treatment dissolved in the water to affect the entire parasite burden.\nCiliates, external worms, parasitic crustaceans, fungal hyphae growing on dead tissue, and other accessible objects can be removed by rinsing, gentle wiping, forceps, or another suitable method. The choice of technique depends on the fish species, the structure of its body surface, the location of the lesion, and the condition of the animal.\nThe inability to remove every parasite in a single procedure is not a reason to leave all parasites on the fish.\nPractical example: mechanical reduction of the parasite burden in cryptocaryonosis\rCryptocaryonosis: killing the parasite or treating the water?\rA practical analysis of cryptocaryonosis treatment in marine fish: why killing the parasite should not become more important than the …\rIf a fish dies during non-traumatic handling (bathing, transfer): Necropsy may reveal irreversible changes that could have caused death on their own.\nStress only triggered the death, which would have occurred soon anyway.\nSo don’t blame yourself immediately — perform a necropsy and then draw conclusions.\nMost likely, the fish was already “doomed.”\nIf fungal hyphae (Saprolegnia) appear on the body : More often, the oomycete attaches to necrotic areas of skin or gills.\nIf the hyphae look like white fluff, it is most likely a saprophyte — not the cause, but a consequence, an indicator.\nIn “aggressive” oomycetes, the hyphae spread along the skin. The coating is denser, resembling wet cotton, and individual filaments are not visible.\nIf fungal hyphae are present on the fish: Treat bacterial infection at the same time.\nBacteria, ciliates, and flagellates always thrive in these fungal “thickets.”\nDo not confuse bacteria with fungi — the size difference is enormous.\nFungal hyphae are thicker and show internal structure. FAQ If a fish eats, is it healthy?\nNo. Appetite does not guarantee health.\nWhy do different species die at once?\nMost often due to water conditions, not infection.\nShould treatment start immediately after deaths?\nNo. The cause must be identified first.\nHow many fish should be examined?\nSeveral, to distinguish individual from systemic issues.\nIs Saprolegnia the cause of death?\nUsually not. It is a secondary colonizer.\n","permalink":"https://fossamethod.ru/en/posts/rules/","summary":"\u003cbr style=\"clear: both\"\u003e\r\n\u003chr\u003e\n\u003cbr style=\"clear: both\"\u003e\r\n\u003ch3 id=\"if-fish-are-dying-in-the-aquarium-for-unknown-reasons\"\u003eIf fish are dying in the aquarium for unknown reasons:\u003c/h3\u003e\n\u003col\u003e\n\u003cli\u003eTransfer all fish to another tank.\u003c/li\u003e\n\u003cli\u003eInvestigate what is happening.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eMass mortalities can vary:\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eDifferent species are dying simultaneously.\u003c/strong\u003e\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003eDifferent genera and families have distinct lifestyles, physiology, and immune responses. If multiple species die at once, the cause is more likely water chemistry rather than a pathogen.\u003c/p\u003e\u003c/blockquote\u003e\n\u003cp\u003e\u003cstrong\u003eOne species dies quickly and massively.\u003c/strong\u003e\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003eThis is also often related to water chemistry — the most sensitive species reacts first.\u003c/p\u003e","title":"Simple Rules for Working with Aquarium Fish"},{"content":" Surgical Procedures on Aquatic Animals under Anesthesia: Gentle Technique and Cosmetic Suturing Precision and a gentle approach are critical in fish and aquatic animal surgery, especially for rare or valuable specimens. Standard “mattress” or rough sutures commonly used in hatcheries are not suitable—they increase the risk of complications, necrosis, and wound dehiscence.\nOperating Table Setup The main water box with a pump ensures a constant water flow. The working table has a cutout for positioning the fish on its back. The pump tube is inserted into the fish’s mouth, and water flows over the gills. Wet cloth covers the fish to prevent drying. An anesthetic is added to maintain the animal in a stable state throughout the procedure. The dosage of clove oil is 0.35 ml per 10 liters. Such fish are very sensitive to it.\nAdding anesthetic to the water Inspecting the animal Performing the surgical procedure Anatomy Considerations Affecting Suture Choice Fish skin is dense and tendon-like, easily detaching from muscle and slow to reattach. Detached skin sections necrotize quickly. Muscle fibers run perpendicular to the needle path, making rough sutures unreliable. To avoid necrosis and ensure wound sealing :\nSuperficial skin layers prone to necrosis are excised at an angle. Cosmetic sutures are applied parallel to the incision, keeping threads inside the tissue to approximate muscle edges. Muscle layers are sutured in two layers using a curved needle, minimizing water intrusion and accelerating healing. Removing foreign objects Tissue preparation and cosmetic suturing Intestinal Suturing Technique The intestine is incised carefully to avoid major blood vessels. Hemostasis is achieved using a coagulator.\nInvaginating intestinal suture After removing foreign bodies or completing the target procedure, a simple “edge-to-edge” suture is applied for fixation. Then, an internal invaginating suture is placed, turning edges inward. This prevents adhesion with other organs and maintains smooth intestinal surfaces.\nResults For a 40-cm kaluga, this technique showed high effectiveness:\nNo necrosis in the operated area Hermetic sutures preventing water entry Minimal scarring Fish resumed eating within three days without complications One year later Conclusion Using cosmetic skin suturing combined with internal intestinal sutures and anesthesia allows surgical procedures on aquatic animals to be performed gently. This is especially crucial for valuable or singular specimens, where each chance of successful recovery matters.\nREFERENCES Harms C. Surgery in Fish Research: Common Procedures and Postoperative Care // Lab Anim. 2005. Т. 34. С. 28–34. Harms C. A., Lewbart G. A. Surgery in fish // Veterinary Clin. North Am. Exot. Anim. Pract. 2000. Т. 3. № 3. С. 759–774. FAQ Can fish undergo surgery? Yes, with proper anesthesia and technique.\nWhy is water supplied through the mouth? To maintain gill ventilation during the procedure.\nWhy are standard sutures unsuitable? They increase tissue damage and risk of necrosis.\nWhat is the advantage of cosmetic sutures? They minimize trauma and improve healing.\nIs surgery risky for fish? Yes, but risks can be reduced with proper methods.\n","permalink":"https://fossamethod.ru/en/posts/operation/","summary":"\u003cbr style=\"clear: both\"\u003e\n\u003ch3 id=\"surgical-procedures-on-aquatic-animals-under-anesthesia-gentle-technique-and-cosmetic-suturing\"\u003eSurgical Procedures on Aquatic Animals under Anesthesia: Gentle Technique and Cosmetic Suturing\u003c/h3\u003e\n\u003cbr style=\"clear: both\"\u003e\n\u003cp\u003ePrecision and a gentle approach are critical in fish and aquatic animal surgery, especially for rare or valuable specimens. Standard “mattress” or rough sutures commonly used in hatcheries are not suitable—they increase the risk of complications, necrosis, and wound dehiscence.\u003c/p\u003e\n\u003cbr style=\"clear: both\"\u003e\n\u003ccenter\u003e\n\r\n\r\n\r\n\r\n\u003ciframe src=\"/en/post/Operation/HirTable.html\" width=\"100%\" height=\"400\" frameborder=\"1\" allowfullscreen\u003e\u003c/iframe\u003e\n\u003c/center\u003e\n\u003cbr style=\"clear: both\"\u003e\n\u003ch3 id=\"operating-table-setup\"\u003eOperating Table Setup\u003c/h3\u003e\n\u003cbr style=\"clear: both\"\u003e\n\u003cul\u003e\n\u003cli\u003eThe main water box with a pump ensures a constant water flow.\u003c/li\u003e\n\u003cli\u003eThe working table has a cutout for positioning the fish on its back.\u003c/li\u003e\n\u003cli\u003eThe pump tube is inserted into the fish’s mouth, and water flows over the gills. Wet cloth covers the fish to prevent drying.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003e\u003cem\u003eAn anesthetic is added to maintain the animal in a stable state throughout the procedure.\u003c/em\u003e The dosage of clove oil is 0.35 ml per 10 liters. Such fish are very sensitive to it.\u003c/p\u003e","title":"Surgical Procedures on Aquatic Animals"},{"content":"\nToggle Myth / Reality\rMyth \u0026ldquo;Only Fresh Fish Can Be Examined\u0026rdquo; There’s a common belief that if a fish dies in an aquarium, an autopsy is pointless. It’s often claimed that you must dissect immediately after death, otherwise nothing useful can be learned. The reasoning goes like this: fish decompose very quickly at room temperature — within minutes, tissues change, organs lose structure, and parasites either die or abandon the host. Aquariums are “full of bacteria,” so decomposition starts instantly. Organs can’t be assessed accurately — color, consistency, and integrity are distorted. Surfaces get covered by bacteria, making it impossible to distinguish pathogens from postmortem contamination. Parasites leave the dying host, and the remaining ones die quickly. Organisms found later may just be saprophytes and misinterpreted as disease agents. The conclusion often drawn: if a fish has been dead for even a short time, there’s no point in examining it — you can’t identify pathologies or parasites.\nReality \u0026ldquo;Fish that died in the aquarium should not be dissected!\u0026rdquo; Ваш браузер не поддерживает видео. Fish necropsy That statement is misleading. Even in human forensic medicine, bodies are examined long after death. Why should fish be an exception? Research in pathology and forensic science shows that diagnostic features often remain visible for hours, sometimes days, if interpreted correctly.\n\u0026ldquo;Tissues change within minutes\u0026rdquo; Yes, changes begin after death, but that doesn’t make organs useless. Veterinary and medical pathology accounts for stages of autolysis and evaluates decomposition in context. Fish metabolism is fast, but at normal room temperatures, significant structural loss takes longer than “a few minutes.” This is where experience and logic matter most — interpretation is key.\n\u0026ldquo;Parasites die or leave the host\u0026rdquo; — is that true? Where would they go? Most fish parasites have life stages that do not include active relocation between hosts. Parasites are adapted for minimal activity — that’s why so many lack eyes, limbs, or even advanced organs. Even parasitic crustaceans, once attached, transform into sedentary forms focused solely on reproduction.\nIf an adult parasite detached, it would likely die. Even ciliates like Cryptocaryon or Ichthyophthirius can’t actively swim once they enlarge for division — their cilia are too small relative to body size. Some species, like Monogenea, have a free-swimming larval stage (oncomiracidium), but only during initial colonization, not after maturation. Mature forms equipped with hooks for attachment cannot “crawl around the tank” looking for new hosts (Buchmann \u0026amp; Lindenstrøm, 2002; Olstad et al., 2006).\nIn reality, most parasites remain on the host until they themselves die — usually because bacteria begin breaking down the tissue. Protozoans can still be identified morphologically for hours postmortem, especially in smears, imprints, or stained samples (Tarannum et al., 2023).\rLater, when decomposition advances, they disintegrate completely. Bacteria don’t flood the body instantly\nThey don’t “burst out” of the gut the moment the fish dies. Tissue structure acts as a barrier (Brooks, 2016; Mesli et al., 2017). If there were no bacterial colonies on internal organs during life, they won’t magically appear immediately after death. And postmortem cannot create lesions typical of infection — ulcers, hyperemia, granulomas simply don’t develop after death.\nDecomposition takes time. Even at 22–27 °C, bacterial growth and tissue breakdown progress slower than intuition suggests. Lower temperatures slow it even more.\r\u0026ldquo;There are lots of bacteria in the aquarium, so decomposition is instant\u0026rdquo; “Lots” is relative. Think about this: why is fresh tap water cloudy right after filling an aquarium — and why does it clear after standing for a day or two?\nFact: That’s physics, not bacteria.\nCloudiness comes from microbubbles released when water pressure drops (pipes run at higher pressure than the room). Within 12–48 hours, gases escape, and water clears — not because “bacteria died,” but because bubbles disappeared.\nFor a true bacterial bloom, you need: Organic matter (food) Time (hours to days for exponential growth) Conditions (nutrients) Clean tap water is extremely poor in organics. A “sudden bloom” from nothing is impossible. \u0026ldquo;Some organisms found on a dead fish are mistaken for the cause of death\u0026rdquo;\nTrue — but that’s not a reason to skip necropsy. In forensic work, insects on a body aren’t mistaken for the cause of death — trained professionals interpret evidence properly. The solution isn’t “don’t look,” it’s “learn to interpret.” Don’t confuse risk of misinterpretation with uselessness of examination.\nReference Brooks, J.W., 2016. Postmortem Changes in Animal Carcasses and Estimation of the Postmortem Interval. Vet Pathol 53, 929–940. https://doi.org/10.1177/0300985816629720\nBuchmann, K., Lindenstrøm, T., 2002. Interaction between monogenean parasites and their fish host. International journal for parasitology 32, 309–19. https://doi.org/10.1016/S0020-7519(01)00332-0\nMesli, V., Neut, C., Hedouin, V., 2017. Postmortem bacterial translocation, in: Forensic Microbiology. pp. 192–211. https://doi.org/10.1002/9781119062585.ch8\nOlstad, K., Cable, J., Robertsen, G., Bakke, T.A., 2006. Unpredicted transmission strategy of Gyrodactylus salaris (Monogenea: Gyrodactylidae): survival and infectivity of parasites on dead hosts. Parasitology 133, 33–41. https://doi.org/10.1017/S0031182006009966\nTarannum, A., Rodríguez-Almonacid, C.C., Salazar-Bravo, J., Karamysheva, Z.N., 2023. Molecular Mechanisms of Persistence in Protozoan Parasites. Microorganisms 11, 2248. https://doi.org/10.3390/microorganisms11092248\nFAQ Can a fish be examined hours after death? Yes. Diagnostic features can remain visible for hours. The key is to interpret postmortem changes correctly, not to avoid examination.\nWhat happens to tissues after death? Autolysis begins, but it is a gradual process. Structural and morphological features often remain identifiable for a considerable time.\nDo parasites leave the host after death? No. Most parasites remain in place and gradually degrade along with host tissues. They do not actively leave the body.\nCan bacteria mislead the diagnosis? Yes, if interpreted incorrectly. Postmortem bacterial growth can occur, but it does not create disease-specific lesions from scratch.\nWhen does an autopsy become useless? When tissue structure is completely destroyed and no meaningful morphology remains. This takes time and depends on environmental conditions.\n","permalink":"https://fossamethod.ru/en/posts/fish-autopsy-myth/","summary":"\u003cbr\u003e\r\n\r\n\r\n  \r\n  \r\n  \r\n  \r\n\r\n  \r\n  \r\n  \r\n    \r\n  \r\n\r\n  \r\n\r\n  \u003cdiv id=\"Fresh\" class=\"toggleblock myth-reality\"\u003e\r\n    \u003cbutton class=\"toggle-btn\" onclick=\"toggleBlock('Fresh')\"\u003eToggle Myth / Reality\u003c/button\u003e\r\n    \u003cdiv class=\"toggle-content first\"\u003e\u003ch2 id=\"myth\"\u003eMyth\u003c/h2\u003e\n\u003cbr\u003e\r\n\u003ch3 id=\"only-fresh-fish-can-be-examined\"\u003e\u0026ldquo;Only Fresh Fish Can Be Examined\u0026rdquo;\u003c/h3\u003e\n\u003cp\u003eThere’s a common belief that if a fish dies in an aquarium, an autopsy is pointless. It’s often claimed that you must dissect immediately after death, otherwise nothing useful can be learned. The reasoning goes like this: fish decompose very quickly at room temperature — within minutes, tissues change, organs lose structure, and parasites either die or abandon the host.\n\u003cbr style=\"clear: both\"\u003e\u003c/p\u003e","title":"Is It Ever Too Late for a Fish Autopsy?"},{"content":"\nThe \u0026ldquo;perception loop\u0026rdquo; of medications:\nenthusiasm → widespread use → side effects → fear and rejection → rational balance.\nIt\u0026rsquo;s time to move on to the final stage\u0026hellip;\nToggle Avers / Revers\rMedications as a Lifeline Methylene Blue Antiseptic and mild detoxifier. Supports tissue recovery and oxygen balance. Useful for diagnostics and treating fry. Methylene blue is one of the safest and most accessible dyes in fishkeeping.\nIt helps in cases of nitrite poisoning, improves tissue oxygenation, and acts as a general antiseptic.\nUsed for treating fungal infections on eggs, for short baths, and diagnostic staining.\nEasy to prepare, easy to use — even for delicate or juvenile fish.\nFormalin Still effective against Cryptocaryon, Ichthyophthirius, and monogeneans. Works on early stages and external parasites. Included in quarantine protocols in research and public aquaria. Formalin (formaldehyde solution) remains a potent antiparasitic.\nIt can be used in short baths, dips, or system-wide treatments.\nPenetrates mucus layers and damages cyst walls.\nOften combined with malachite and methylene blue in FMC protocols.\nMalachite Green Powerful antifungal and antiparasitic. Effective even in low concentrations. Fast results, easy visual feedback. Malachite green oxalate is highly effective against Ichthyophthirius, Saprolegnia, Trichodina, and other ectoparasites.\nUsed in baths, dips, or low-dose long-term exposure.\nDespite being a synthetic dye, it has remained in use for decades due to consistent performance.\nEspecially helpful in emergency outbreaks or egg disinfection.\nFMC ( Formalin + Malachite + Methylene Blue ) A historic \u0026ldquo;golden mix\u0026rdquo; — each component targets a different threat. Simple to use, low-cost, highly visible effect. Popular for general parasite prevention or in early-stage treatment. Once seen as an all-purpose solution, FMC became a ritual in fish medicine.\nIts popularity stemmed from simplicity, not always from evidence.\nAntibiotics Can stop systemic infections. Life-saving in advanced septicemia or gill diseases. When used correctly, antibiotics like oxytetracycline, erythromycin, or nitrofurans help treat bacterial infections: Aeromonas, Pseudomonas, Mycobacterium spp.\nProper dosing, good water quality, and follow-up care are key. Without antibiotics, fish often die en masse in infected tanks.\nControlled use can restore populations in both private and public systems.\nMedications as a Hidden Threat Methylene Blue Can interfere with metabolic enzymes. May cause kidney stress with repeated use. Hides underlying issues without addressing root causes. Chronic or careless use of methylene blue can stain tissues and disrupt liver function.\nIt also impacts beneficial nitrifying bacteria, especially in bioactive systems.\nMisuse creates the illusion of treatment — while the real issue remains undiagnosed.\nFormalin Toxic and carcinogenic. Damages gills, kidneys, and liver. Risky in poorly aerated or overstocked systems. Formaldehyde is a known mutagen and toxicant.\nIt burns skin and gills, stresses fish with liver/kidney pathology, and consumes oxygen.\nWithout extra aeration, it can cause suffocation and acute stress.\nUsed blindly, it often causes more harm than the parasite itself.\nMalachite Green Banned in many countries due to carcinogenic risk. Toxic to some species, especially catfish and scaleless fish. While effective, malachite green accumulates in tissues and is not safe for food fish.\nOverdoses cause severe gill damage and death.\nEven at normal levels, it stresses sensitive fish and can suppress immunity.\nIts use in public aquaria is increasingly questioned.\nFMC (formalin + malachite green + methylene blue) Frequently ineffective when used in short 5–15 minute dips. Parasites often survive, while fish are weakened. Can create false confidence — “something was done” — but no true cure. Formalin and malachite together increase toxicity, especially in stressed fish. Methylene blue harms biofilters — water degrades fast in closed systems. Lacks proper diagnostics, context, or outcome tracking. FMC was once the \u0026ldquo;go-to\u0026rdquo; blend. Now, it\u0026rsquo;s often used as a ritual — with little consideration for water quality, fish health, or actual results.\nIf parasites survive and the fish becomes weaker — that’s not medicine, it’s a mistake.\nAntibiotics Promote resistance (Aeromonas, Pseudomonas, etc.). Kill gut microbiota. Leave residues that affect the whole aquarium system. Without lab diagnostics (cultures, antibiograms), antibiotics are often useless or harmful.\nThey destroy healthy bacteria, trigger dysbiosis, and create resistant strains.\nSurviving pathogens come back stronger.\nLong-term, residual antibiotics destabilize closed systems and reduce resilience.\nWhy do these outdated practices persist? Because no proper treatment records are kept.\nNo microscope photos, no dosage logs, no post-treatment analysis — no way to tell if something helped or hurt.\nTo move past ritual and toward results, aquarists and institutions need proper treatment logs and data systems — with diagnostics, follow-ups, and outcome-based decisions.\nOnly then can we separate science from superstition.\nREFERENCES Lindholm‐Lehto P., Pylkkö P. Saprolegniosis in aquaculture and how to control it? // Aquac. Fish Fish. 2024. Vol. 4. Mooney A. Malachite Green found in Shrimp exports from Bangladesh [Electronic resource] // Randox Food. 2023. URL: https://mta-sts.randoxfood.com/malachite-green-found-in-shrimp-exports-from-bangladesh/ (accessed: 04.07.2025). Transcriptome analysis of zebra fish (Danio rerio) eggs following treatment with malachite green // Aquaculture. Elsevier, 2020. Vol. 514. P. 734500. Srivastav A. Malachite green (Triarylmethane dye) and Pyceze (Bronopol) induced histopathological and biochemical changes in the liver of a catfish Heteropneustes fossilis (Bloch.) // Indian J. Fish. 2016. Vol. 63. P. 135–139. Rao V., Ajith Kumar T.T., Badhul H. Diseases in the Aquarium Fishes: Challenges and areas of concern. // Int. J. Environ. 2013. Vol. 2. Sudova E. et al. Negative effects of malachite green and possibilities of its replacement in the treatment of fish eggs and fish: a review // Veterinární Medicína. Veterinární medicína, 2007. Vol. 52, № 12. P. 527–539. Srivastava S., Sinha R., Roy D. Toxicological effects of malachite green // Aquat. Toxicol. Amst. Neth. 2004. Vol. 66, № 3. P. 319–329. Saglam N., Ispir U., Yonar M. The Effect of Therapeutic Bath of Malachite Green on Some Haematological Parameters of Rainbow trout (Oncorhynchus mykiss, Walbaum, 1792) // Fresenius Environ. Bull. 2003. Campbell R.E. et al. In vitro screening of novel treatments for Aphanomyces invadans // Aquac. Res. 2001. Vol. 32, № 3. P. 223–233. Culp S.J., Beland F.A. Malachite Green: A Toxicological Review // J. Am. Coll. Toxicol. SAGE Publications, 1996. Vol. 15, № 3. P. 219–238. Bly J. et al. Therapeutic and prophylactic measures for winter saprolegniosis in channel catfish // Dis. Aquat. Organ. Inter-Research Science Center, 1996. Vol. 24. P. 25–33. FAQ Can multiple drugs be used at once?\nYes, but this increases stress on fish and the system.\nIf a drug worked once, is it universal?\nNo. Effectiveness depends on the actual cause.\nWhy can treatment make things worse?\nBecause many drugs are toxic and affect weakened fish.\nAre formalin and malachite green safe?\nNo. They are effective but potentially harmful.\nCan treatment be done without diagnosis?\nYes, but it becomes guesswork rather than medicine.\n","permalink":"https://fossamethod.ru/en/posts/medicines_poisons/","summary":"\u003cbr\u003e\r\n\u003cblockquote\u003e\n\u003cblockquote\u003e\n\u003cp\u003e\u003cstrong\u003eThe \u0026ldquo;perception loop\u0026rdquo; of medications:\u003c/strong\u003e\u003cbr\u003e\nenthusiasm → widespread use → side effects → fear and rejection → \u003ccode\u003erational balance\u003c/code\u003e.\u003cbr\u003e\nIt\u0026rsquo;s time to move on to the final stage\u0026hellip;\u003c/p\u003e\u003c/blockquote\u003e\u003c/blockquote\u003e\n\u003cbr\u003e\r\n\r\n\r\n  \r\n  \r\n  \r\n  \r\n\r\n  \r\n  \r\n  \r\n    \r\n  \r\n\r\n  \r\n\r\n  \u003cdiv id=\"Medicines\" class=\"toggleblock avers-revers\"\u003e\r\n    \u003cbutton class=\"toggle-btn\" onclick=\"toggleBlock('Medicines')\"\u003eToggle Avers / Revers\u003c/button\u003e\r\n    \u003cdiv class=\"toggle-content first\"\u003e\u003ch2 id=\"medications-as-a-lifeline\"\u003eMedications as a Lifeline\u003c/h2\u003e\n\u003cbr\u003e\r\n\u003cul\u003e\n\u003cli\u003e\n\u003ch3 id=\"methylene-blue\"\u003eMethylene Blue\u003c/h3\u003e\n\u003cul\u003e\n\u003cli\u003eAntiseptic and mild detoxifier.\u003c/li\u003e\n\u003cli\u003eSupports tissue recovery and oxygen balance.\u003c/li\u003e\n\u003cli\u003eUseful for diagnostics and treating fry.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eMethylene blue is one of the safest and most accessible dyes in fishkeeping.\u003cbr\u003e\nIt helps in cases of nitrite poisoning, improves tissue oxygenation, and acts as a general antiseptic.\u003cbr\u003e\nUsed for treating fungal infections on eggs, for short baths, and diagnostic staining.\u003cbr\u003e\nEasy to prepare, easy to use — even for delicate or juvenile fish.\u003c/p\u003e","title":"Two Sides of One Dosage"},{"content":" Let’s say your name is Lena. Or Tanya. Or maybe Alex.\nIt doesn’t matter — what matters is that you’re curious, willing to improve your work with aquatic animals, and finally have access to a microscope (congrats!). You even got some stains? Then let’s begin.\n*And please — wear gloves. Not just for your own safety, but for the fish. Their slime coat is thin and fragile after transport, and they don’t need extra stress from human skin contact. *\n1. Unpacking the Fish The fish has spent hours in a plastic bag — **little water, lots of air**, no food before shipment. Waste builds up. The water degrades. Bacteria start to multiply. Gently scrape with a coverslip. Used to collect mucus and surface cells. Press to a wound, then lift. That\u0026#39;s an imprint smear. Lots of bacteria. A real mess. It’s entropy at work. Fish feces are there. Bacterial growth is inevitable.\nThe best thing you can do? Take skin or wound smears in the first hour after unpacking.\nBasic Staining — Löffler\u0026rsquo;s Methylene Blue This method gives a quick overview of tissue damage, bacterial presence, fungal elements, etc.\nPrepare a saturated alcoholic methylene blue solution:\n1.6 g in 100 mL of 95% ethanol.\nMix 30 mL of that with 100 mL of 0.01% KOH solution. (0.01 g KOH in 100 mL distilled water)\nFinal concentrations per 100 mL:\nMethylene blue – 0.37 g\nEthanol – 23.08 mL\n0.01% KOH – 76.92 mL\nStaining time: 10–30 seconds. That’s it.\nPolymicrobial Smears Ways to describe such a smear: polymicrobial conglomerate pleomorphic bacterial mass heterogenous community mixed biofilm bacterial debris field polyculture contamination Many bacteria, none dominant. “If the smear looks like bacterial soup — various shapes, sizes, forms — it’s probably just dirt. Not an infection, but a microbial mess caused by bad water, stress, temperature swings. ” Monomicrobial Smears Ways to describe such a smear: monomorphic bacterial colony homogeneous cluster pure culture pattern uniform pathogen presence mono-infection profile One type dominating. Infection likely. “If all bacteria look the same — same shape, same size, same reaction — that’s a red flag. Likely a dominant pathogen multiplying aggressively.” This situation usually requires:\nbacterial culture (for ID) antibiotic susceptibility testing treatment What If You See Ulcers?\nUlcers may host mycobacteria, including Mycobacterium marinum (fish TB). These don’t show up with simple stains.\nUse Ziehl stain (modified for fish pathology).\nZiehl’s Fuchsin Solution:\n1 g basic fuchsin in 10 mL 96% ethanol Add to 5% phenol solution (100 mL) Let it sit 48h and filter Staining steps:\nFix smear (air-dry + flame) Add filter paper, apply Ziehl stain Heat until vapor appears (briefly!) Let cool, rinse with water Decolorize in 5% sulfuric acid (dip 2–3 times) Rinse and counterstain with Löffler’s methylene blue Result:\nRed = acid-fast bacteria (e.g., mycobacteria) Blue = background tissue \u0026amp; non–acid-fast Acid-fast bacteria don\u0026#39;t show up in basic stains. Ziehl stain; counterstain is malachite green, not methylene blue. This malachite green counterstain is shown here instead of methylene blue. Both work — just helps you see structure differently. 2. Toxicosis from Transport Methylene blue isn’t just a dye — it helps detoxify by acting as an electron acceptor/donor. It can convert methemoglobin back into hemoglobin and reduce oxidative stress in fish. Use low-dose methylene blue immediately after unpacking — it might save lives.\nUntreated toxicosis can lead to kidney necrosis, slow death, and delayed mortality within weeks. 3. Quarantine If no severe infection is found: Let the fish rest for 1–3 days. Observe. Then decide. If anything is suspicious — don’t rush into harsh chemical baths. Many people throw new fish into formalin/malachite green (FMC) straight away. That’s harmful, not helpful. ⚠️ Gentle Rinse, Not a Chemical War\nIf fish are small and manageable — rinse them manually, in slightly different salinity. Wear gloves.\nMarine fish → briefly in freshwater Freshwater fish → briefly in saline water No FMC needed unless really justified Physical slime removal helps more than short chemical exposure. Long-Term: Keep Watching\nIn the following days — take new smears, collect feces, and monitor.\nSome common threats by water type:\nTropical Saltwater (TS) :\nSkin: Bacteria, Cryptocaryon irritans, Monogeneans (Capsalidae) Internal: Cryptobia, Hexamita, Spironucleus, Trichomonas Tropical Freshwater (TF):\nSkin: Bacteria, fungi, Ichthyophthirius, Ichthyobodo Internal: Cryptobia, Hexamita, Spironucleus, Trichomonas, nematodes Cold Saltwater (CS):\nSkin: Fungi, bacteria — slower development, easier to treat Cold Freshwater (CF):\nSkin: Trichodina, Chilodonella, Ichthyophthirius, Ichthyobodo, fungi, Gyrodactylus Internal: Bacteria, fungi, cestodes Find them all in the Gallery Fungi are usually much larger than bacteria — don’t confuse them in smears!\nFungal hyphae are thicker and more structured than bacteria. FAQ Should fish be treated immediately after transport? No. First, assess their condition.\nWhy are there many bacteria in smears? Usually due to transport-related contamination.\nWhen are bacteria a concern? When a uniform (monomorphic) population dominates.\nIs culture always necessary? Only when infection is suspected.\nWhy take smears at all? To quickly assess the situation.\nSee also: ","permalink":"https://fossamethod.ru/en/posts/coming/","summary":"\u003cstyle\u003e\n \n    details \u003e summary {\n        padding: 5px;\n        background-color: #7A949BFF;\n        color: #333;\n        border: 1px #FFFFFFFF solid;\n        cursor: pointer;\n        list-style: none;\n        font-weight: bold;\n    }\n \n    details \u003e div {\n        border: 1px #ccc solid;\n        padding: 10px;\n    }\n \ndetails[open] \u003e summary {\n    color:#eee; \n   background-color:#333;\n}\nsummary:before {\n   content: \"+\";\n   font-size: 20px;\n   font-weight: bold;\n   margin: -5px 5px 0 0;\n}\n \ndetails[open] summary:before {\n   content: \"-\";\n}\n\u003c/style\u003e\n\u003cblockquote\u003e\n\u003c/blockquote\u003e\n\u003cp\u003e\u003cstrong\u003eLet’s say your name is Lena. Or Tanya. Or maybe Alex.\u003c/strong\u003e\u003c/p\u003e\n\u003cblockquote\u003e\n\u003c/blockquote\u003e\n\u003cp\u003eIt doesn’t matter — what matters is that you’re curious, willing to improve your work with aquatic animals, and finally have access to a microscope (congrats!). You even got some stains? Then let’s begin.\u003c/p\u003e","title":"Initial Diagnostics After Fish Transportation"},{"content":"\rToggle Myth / Reality\rMisconceptions - In most cases, the disease is caused by supersaturation of water with nitrogen, less commonly oxygen. This typically happens when water is heated in closed systems where gases cannot freely escape — such as heat exchangers in power plants or boilers in hatcheries. - Air bubbles in the water, on glass, or on plants are dangerous — they can block the gills of fish and cause death. - External signs of gas embolism appear a few hours after fish are placed in supersaturated water. The higher the gas saturation level, the faster the symptoms develop and the sooner the fish may die. At lower saturation levels, fish may survive longer, and signs like the location and shape of bubbles become more variable. - During necropsy of larger fish, foamy blood may emerge from blood vessels. Other signs include: hyperactivity, hypersensitivity to mechanical stimuli, loss of balance, twitching fins, scale erection, ray separation, corneal opacity, lightening or darkening of body coloration, loss of vision, exophthalmia. - Causes may include: excessive oxygen production by plants, overly aggressive artificial aeration, or the use of untreated tap water. The disease develops in conditions of oxygen and nitrogen oversaturation. - Oxygen entering the bloodstream in excess forms tiny bubbles that block blood vessels. When bubbles enter capillaries, they are often larger than the vessel’s diameter, and the heart is not strong enough to push them through — resulting in blockage. The diagnosis is based on clinical signs, necropsy findings, and water analysis, specifically the level of dissolved oxygen. Scientific Perspective Under increased pressure, bubbles do not form. Gas molecules remain dissolved, mixing with water molecules. Gas Bubble Disease (GBD) is a pathological condition in which free gas bubbles form within the blood and tissues of fish. These bubbles impair circulation, damage the gills and internal organs, cause tissue ischemia, and may ultimately lead to death.\nAt first glance, the explanation seems obvious: if bubbles are present in the water, they must enter the fish and cause the disease.\nThis is exactly how gas bubble disease is described in many articles, books, and even textbooks.\nHowever, this explanation is incorrect.\nGas bubble disease does not develop because fish come into contact with air bubbles. It develops because the water contains an excessive amount of dissolved gases. These are fundamentally different phenomena.\nThe bubbles visible in an aquarium and the bubbles forming inside a fish\u0026rsquo;s blood vessels have completely different origins.\nWhat causes Gas Bubble Disease? The primary cause of GBD is gas supersaturation.\nUnder certain conditions, water can dissolve more gas than would normally exist at equilibrium for a given pressure and temperature. In most cases, the excess consists mainly of nitrogen, less commonly oxygen or a mixture of atmospheric gases.\nAs long as pressure remains elevated, the excess gas may remain completely dissolved. The water appears perfectly clear, even though it actually contains more dissolved gas than equilibrium allows.\nThis is the dangerous condition.\nWhen water contains excess dissolved gases, the partial pressure of these gases at the gill surface becomes higher than in the blood. A diffusion gradient is established, allowing gases to diffuse across the gill epithelium until a new equilibrium is reached.\nThis is how gas bubble disease develops.\nWhere do the bubbles form? Elongated gas bubbles within the fin blood vessels. Their characteristic shape indicates formation inside the bloodstream under pressure. This is one of the most important questions.\nGas bubbles do not enter the fish from the surrounding water.\nInstead, they form inside the body, when dissolved gases can no longer remain in solution within the blood and tissue fluids.\nTherefore, finding bubbles inside blood vessels does not mean they entered through the gills. They formed exactly where dissolved gas came out of solution.\nThe same physical mechanism is well known outside ichthyopathology. It is responsible for decompression sickness in divers.\nWhy may there be no visible bubbles at all? This is where the most common misconception begins.\nMost people judge the risk by the number of bubbles visible in the water.\nIn reality, the opposite is often true.\nUnder elevated pressure, water can hold a large amount of dissolved gas without forming bubbles. The gas remains completely dissolved and therefore invisible.\nWhen pressure decreases, gas solubility decreases as well, and the excess gas begins to leave the solution as visible bubbles.\nIn other words, visible bubbles often indicate not the beginning of the problem, but that the water has already started releasing excess dissolved gas.\nPressure keeps gases dissolved Ваш браузер не поддерживает видео. Pressure affects gas solubility. This process is described by Henry\u0026rsquo;s Law.\nThe amount of gas that water can hold is determined by its partial pressure.\nC = kH × P\nwhere:\nC — concentration of dissolved gas;\nkH — Henry\u0026rsquo;s constant;\nP — partial pressure of the gas.\nThe practical implication is straightforward.\nIncreasing pressure allows water to dissolve more gas.\nWhen pressure subsequently decreases, gas solubility falls, and the excess gas begins to leave the solution.\nThis is why elevated pressure within water treatment systems can create conditions for gas supersaturation, whereas visible bubbles often appear only after pressure has decreased.\nWhy is this important? Preventing gas bubble disease is impossible if assessment is based solely on visible bubbles.\nProper preventive measures include:\ncontrolling pressure within the water treatment system; monitoring Total Gas Pressure (TGP), whenever possible; removing excess dissolved gas by aeration or cascade degassing. During necropsy The presence of gas within tissues during necropsy is not, by itself, evidence of gas bubble disease. Postmortem gas formation is a common consequence of carcass warming and autolysis. As temperature rises, gas solubility decreases, allowing dissolved gases to leave solution and accumulate within blood vessels and beneath serosal membranes.\nTherefore, gas observed during necropsy may reflect not only processes that occurred during life, but also postmortem changes.\nPractical observation Based on our observations, conventional aquarium pumps rarely generate a level of gas supersaturation sufficient to produce classical gas bubble disease by themselves.\nEven with air entrainment and pressure increases of approximately 0.5 bar above atmospheric pressure, the increase in gas solubility remains limited and is generally not associated with the characteristic clinical signs of the disease.\nRisk arises when several factors occur simultaneously:\nair entering the pressurized pipeline; gas accumulation under elevated pressure; rapid pressure reduction (decompression). Only the combination of these factors is likely to produce hazardous gas supersaturation.\nConclusion Gas bubble disease does not develop because bubbles enter the fish.\nIt develops because the water contains an excess of dissolved gases.\nThe bubbles visible in an aquarium are more often a consequence of degassing than the cause of the disease.\nTherefore, diagnosis should focus not on the bubbles themselves, but on identifying the conditions that lead to gas supersaturation.\nREFERENCES Legendre D, Zenit R. Gas bubble dynamics. Published online January 6, 2025. doi:10.48550/arXiv.2501.02988 Chen X, Zhang Z, Qin Y, et al. An in-situ study in the Xijiang River basin revealed adverse effects of total dissolved gas supersaturation on fish. Ecotoxicol Environ Saf. 2025;289:117663. doi:10.1016/j.ecoenv.2024.117663 Hong WH, Choi JY, Cho HS, et al. Gas bubble disease in captive Golden Trevally: Pathological insights and needs for life support system and water quality management. J Aquat Anim Health. 2024;36(4):348-354. doi:10.1002/aah.10237 Máchová J, Faina R, Randak T, et al. Fish death caused by gas bubble disease: A case report. Veterinární Medicína. 2017;62:231-237. doi:10.17221/153/2016-VETMED Pleizier NK, Brauner CJ. Causes and consequences of gas bubble trauma on fish gill function. J Comp Physiol B. 2024;194(5):739-747. doi:10.1007/s00360-024-01538-4 Wang H, Wang Y, Li K, Liang R, Zhao W. Tolerance threshold of a pelagic species in China to total dissolved gas supersaturation: from the perspective of survival characteristics and swimming ability. Conserv Physiol. 2024;12(1):coae023. doi:10.1093/conphys/coae023 Causes and consequences of gas bubble trauma on fish gill function - PubMed. Accessed February 24, 2025. https://pubmed.ncbi.nlm.nih.gov/38453727/ Part II. Consequences.\rGas Bubble Disease. Part II. Consequences.\rComparison of normal and pathological findings in fish necropsy: liver, kidney, gills, and brain. How to distinguish acceptable variation …\r--- FAQ Are visible bubbles dangerous? Not necessarily. They often indicate gas release, not accumulation.\nWhy do fish die then? Because of dissolved gas supersaturation, not visible bubbles.\nCan bubbles enter the bloodstream from water? No. They form inside tissues.\nCan the problem be detected visually? Not always. Supersaturation may be invisible.\nDoes cold water cause the disease? No. The key factor is gas supersaturation.\nSee also: ","permalink":"https://fossamethod.ru/en/posts/bublle/","summary":"\u003cdiv id=\"antibiotics\" class=\"toggleblock myth-reality\"\u003e\r\n    \u003cbutton class=\"toggle-btn\" onclick=\"toggleBlock('antibiotics')\"\u003eToggle Myth / Reality\u003c/button\u003e\r\n    \u003cdiv class=\"toggle-content first\"\u003e\u003ch3 id=\"misconceptions\"\u003eMisconceptions\u003c/h3\u003e\n\u003cdiv style=\"clear: both;\"\u003e\u003c/div\u003e\n- In most cases, the disease is caused by supersaturation of water with nitrogen, less commonly oxygen. This typically happens when water is heated in closed systems where gases cannot freely escape — such as heat exchangers in power plants or boilers in hatcheries.\n\u003cdiv style=\"clear: both;\"\u003e\u003c/div\u003e\n- Air bubbles in the water, on glass, or on plants are dangerous — they can block the gills of fish and cause death.\n\u003cdiv style=\"clear: both;\"\u003e\u003c/div\u003e\n- External signs of gas embolism appear a few hours after fish are placed in supersaturated water. The higher the gas saturation level, the faster the symptoms develop and the sooner the fish may die. At lower saturation levels, fish may survive longer, and signs like the location and shape of bubbles become more variable.  \n\u003cdiv style=\"clear: both;\"\u003e\u003c/div\u003e\n- During necropsy of larger fish, foamy blood may emerge from blood vessels. Other signs include: hyperactivity, hypersensitivity to mechanical stimuli, loss of balance, twitching fins, scale erection, ray separation, corneal opacity, lightening or darkening of body coloration, loss of vision, exophthalmia.\n\u003cdiv style=\"clear: both;\"\u003e\u003c/div\u003e\n- Causes may include: excessive oxygen production by plants, overly aggressive artificial aeration, or the use of untreated tap water. The disease develops in conditions of oxygen and nitrogen oversaturation.\n\u003cdiv style=\"clear: both;\"\u003e\u003c/div\u003e\n- Oxygen entering the bloodstream in excess forms tiny bubbles that block blood vessels. When bubbles enter capillaries, they are often larger than the vessel’s diameter, and the heart is not strong enough to push them through — resulting in blockage.\n\u003cdiv style=\"clear: both;\"\u003e\u003c/div\u003e\n\u003cul\u003e\n\u003cli\u003eThe diagnosis is based on clinical signs, necropsy findings, and water analysis, specifically the level of dissolved oxygen.\u003c/li\u003e\n\u003c/ul\u003e\n\u003chr\u003e\n\u003cdiv style=\"clear: both;\"\u003e\u003c/div\u003e\n\u003c/div\u003e\r\n    \u003cdiv class=\"toggle-content second\" style=\"display:none\"\u003e\u003ch3 id=\"scientific-perspective\"\u003eScientific Perspective\u003c/h3\u003e\n\u003cdiv style=\"clear: both;\"\u003e\u003c/div\u003e\n\u003cfigure class=\"float-left zoom-container\" style=\"width: 31%;\"\u003e\n  \u003cimg src=\"https://fossamethod.ru/en/posts/bublle/GIF_gas.gif\"\n       alt=\"Under increased pressure, bubbles do not form. Gas molecules remain dissolved, mixing with water molecules.\"\n       class=\"zoom-image\"\n       loading=\"lazy\"\n       decoding=\"async\"\n       style=\"width: 100%; height: auto; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.1);\"\u003e\u003cfigcaption style=\"font-size: 0.85em; color: #666; margin-top: 0.4em; margin-left: 1em; margin-right: 1em;\"\u003eUnder increased pressure, bubbles do not form. Gas molecules remain dissolved, mixing with water molecules.\u003c/figcaption\u003e\u003c/figure\u003e\u003cscript type=\"application/ld+json\"\u003e\n{\n  \"@context\": \"https://schema.org\",\n  \"@type\": \"ImageObject\",\n  \"contentUrl\": \"http:\\/\\/localhost:52184\\/en\\/posts\\/bublle\\/GIF_gas.gif\",\n  \"name\": \"Under increased pressure, bubbles do not form. Gas molecules remain dissolved, mixing with water molecules.\",\n  \"description\": \"Under increased pressure, bubbles do not form. Gas molecules remain dissolved, mixing with water molecules.\",\n  \"creator\": {\n    \"@type\": \"Person\",\n    \"name\": \"Artem Stepankov\"\n  },\n  \"creditText\": \"Artem Stepankov, Fossa Method\",\n  \"copyrightNotice\": \"© Fossa Method\",\n  \"license\": \"http:\\/\\/localhost:52184\\/en\\/license\\/\",\n  \"acquireLicensePage\": \"http:\\/\\/localhost:52184\\/en\\/contact\\/\"\n}\n\u003c/script\u003e\n\u003cp\u003eGas Bubble Disease (GBD) is a pathological condition in which free gas bubbles form within the blood and tissues of fish. These bubbles impair circulation, damage the gills and internal organs, cause tissue ischemia, and may ultimately lead to death.\u003c/p\u003e","title":"Gas Bubble Disease: It's Not About the Bubbles"},{"content":" Imagine this. A fish arrives at the aquarium with signs of a possible bacterial infection. There\u0026rsquo;s an ulcer, some mucus, a bit of redness. The lab technician takes a sample and sets up a bacterial culture. The results? In 3–5 days. So everyone waits. But the fish is sick now.\nOn paper, this makes sense: the culture will tell us who’s responsible and what antibiotics might work. But meanwhile, the infection progresses. Treatment may already be in progress — and the sample was taken too late. The culture comes back with nothing. People start talking about viruses. The real cause slips through unnoticed.\nBut there was something else we could’ve done — right away.\nWhat could have been done immediately? A simple smear from the affected area, stained and examined under the microscope. Within 10–15 minutes, we could have:\nSeen the bacteria — their shape, clustering, and behavior;\nAssessed the inflammatory response (neutrophils, macrophages, necrosis);\nSpotted a fungus or even a parasite (yes, mucus isn’t always just about bacteria).\nThis kind of approach helps us quickly understand: is this bacterial? Is it acute? Is there invasion? Should we adjust the treatment right away — or maybe take a completely different route? Why is microscopy underestimated?\nIt gives results immediately. No waiting.\nIt doesn’t depend on whether bacteria are still alive. Even dead ones can be seen.\nIt shows how the tissues are reacting — something cultures can\u0026rsquo;t do.\nIt’s cheaper, simpler, and more accessible.\nIt helps avoid treating blind, and supports informed, real-time decisions.\nBut what about bacterial culture? Of course, cultures are important. But they come after microscopy. They help when we want to know exactly what we’re dealing with, and how to treat it precisely. But they only work well under ideal conditions: sterile sample collection, no antibiotics, proper media, right temperature and timing. And above all — the pathogen must actually be capable of growing on that media.\nCases from real life Once, a fish came in with classic signs of a bacterial ulcer. The culture? Nothing grew. But the smear, when stained, showed clusters of diplococci. Turned out, the fish had been treated with antibiotics three days before sampling. The bacteria were dead — but their traces remained in the tissue. That smear saved the day. Based on the morphology and tissue location, a treatment was chosen — and it worked.\rAnd then there’s the reverse story\u0026hellip; Sometimes everything looks fine: clean dissection, no signs of inflammation, no visible lesions in organs. Smears? Completely clean. You begin to suspect non-infectious causes — maybe stress, a gas issue, or a metabolic problem. But then the culture surprises everyone. From seemingly unaffected tissues, a few colonies grow. Not just any bacteria — the “high-alert” ones. Just ten colonies, maybe. But suddenly the diagnosis is made, fingers point, and the assumption becomes: “There it is — the killer.”\rYet something doesn’t add up....\nIf these bacteria were so dangerous, why weren’t they visible in the smear? Why no tissue reaction? Why did the fish die without a fight — no inflammation, no sepsis, nothing?\nThe answer? Sometimes, people believe paper more than pathology. The culture plate becomes sacred. If bacteria grow, the case is closed. But no one asks how or why they were there — or if they were even relevant. A few stray colonies can hijack the entire conclusion.\nThat’s the petri dish illusion: “If it grows, it must be guilty.” Even if the body tells a different story.\nThe takeaway Microscopy isn’t some outdated academic habit. It’s the eyes of the fish pathologist. The first, direct conversation with the disease. A way to act fast and decisively.\nBacterial culture is important. But it’s a confirmation step. The first answer is in the smear.\nFAQ Why not wait for culture results?\nBecause the fish needs treatment immediately.\nIf nothing grows in culture, is there no infection?\nNo. The pathogen may be non-viable or suppressed.\nCan diagnosis be based on a smear alone?\nSometimes, yes. It shows tissue response and structure.\nWhy is culture still needed?\nFor precise identification and antibiotic selection.\nWhich is more important: smear or culture?\nThey complement each other, not replace.\n","permalink":"https://fossamethod.ru/en/posts/smear/","summary":"\u003cblockquote\u003e\n\u003c/blockquote\u003e\n\u003chr\u003e\n\u003cblockquote\u003e\n\u003c/blockquote\u003e\n\u003ch3 id=\"imagine-this\"\u003eImagine this.\u003c/h3\u003e\n\u003cblockquote\u003e\n\u003c/blockquote\u003e\n\u003cp\u003eA fish arrives at the aquarium with signs of a possible bacterial infection. There\u0026rsquo;s an ulcer, some mucus, a bit of redness. The lab technician takes a sample and sets up a bacterial culture. The results? In 3–5 days. So everyone waits. But the fish is sick now.\u003c/p\u003e\n\u003cblockquote\u003e\n\u003c/blockquote\u003e\n\u003cp\u003eOn paper, this makes sense: the culture will tell us who’s responsible and what antibiotics might work. But meanwhile, the infection progresses. Treatment may already be in progress — and the sample was taken too late. The culture comes back with nothing. People start talking about viruses. The real cause slips through unnoticed.\u003c/p\u003e","title":"The Smear Comes First."},{"content":"\rToggle Myth / Reality\rMyth Description: \u0026ldquo;Crypt\u0026rdquo;, \u0026ldquo;marine ich\u0026rdquo;, or \u0026ldquo;white spot disease\u0026rdquo; — Cryptocaryon irritans is a ciliated protozoan parasite, often visible to the naked eye. Tangs, butterflyfish, and boxfish are particularly susceptible and typically among the first to become infected. The free-swimming infectious stage — theront — most often attaches to gills and fins. That’s why these areas should always be examined first.\nOnce mature, the parasite detaches from the host and encysts on the substrate. Around day 3, the tomont undergoes uneven cell division. Between days 6–9, dozens to hundreds of theronts hatch and actively swim away in search of new hosts.\nEach tomont can produce up to 200 theronts, depending on the size of the trophont. Theronts remain viable for no more than 24 hours. Initially, they stay near the cyst, then rapidly disperse. When the gills are infected, the fish begins to suffocate.\nSecondary bacterial infections are common with cryptocaryoniasis. Symptoms include cloudy eyes, frayed fins, and lesions.\nAs is well known, Cryptocaryon follows a slow, multi-stage life cycle. It takes at least 4–5 generations (≈ 1.5 months) to kill a fish through repeated reinfection. Infected fish scratch themselves, triggering a stress response in tankmates — often resulting in an outbreak within hours or days.\nAquarists usually cannot scrape mucus or take a fin sample for microscopic confirmation.\nDiagnosing cryptocaryon based on white spots alone is unreliable.\nSome fish appear to be \u0026ldquo;always sick\u0026rdquo; — showing persistent spots or lesions, which may instead point to improper water conditions. For instance, adding water that is too cold can shock the fish and weaken immunity.\nChronic stress increases cortisol levels, suppresses growth, digestion, and reproduction, and weakens the immune system. This opens the door to parasitic, bacterial, and fungal infections, often resulting in fish death.\nIf there are corals in the tank, they may filter out some theronts. But even in such systems, minor outbreaks are still possible.\nControl Measures UV sterilizers work by irradiating water passing through the chamber and killing microorganisms, including free-swimming Cryptocaryon theronts.\nA properly sized sterilizer (or a diatom filter) can effectively kill theronts in the water column. It doesn’t need to run continuously, but should be activated during quarantine or outbreaks. Run it for 1–2 weeks when introducing new fish or during an infection event.\nSome aquarists never encounter cryptocaryon — not because they’re lucky, but because they maintain excellent water quality and feeding routines.\nNitrogenous compounds like NH₃/NH₄, NO₂, and NO₃ act as toxins. When fish are chronically exposed to them → their immunity drops → pathogens flourish.\nMedications Delagil (chloroquine) is effective against protozoan theronts, similar to those in malaria. Copper-based medications guarantee theront death — if used properly. Ozone alone cannot eliminate Cryptocaryon in a tank. To completely eradicate the parasite, remove all fish from the system and treat them separately for at least one month — ensuring all life stages are broken.\nScience Introduction Infection refers to diseases caused by microorganisms reproducing and acting within the host.\nInfestation (invasion) applies to parasites, including protozoans. While the term \u0026ldquo;protozoan infection\u0026rdquo; is used in human medicine, in ichthyopathology it’s more accurate to say invasion.\nTrophont Cryptocarion irritans In 1951, E. Brown described a parasitic ciliate found on marine fish and named it Cryptocaryon irritans. This parasite affects the skin and gills, impairs physiological function, causes epithelial irritation and hyperplasia, labored breathing, and often leads to secondary bacterial or fungal infections. [Nigrelli, Ruggieri, 1966].\nIn aquariums, conditions can be ideal for parasite reproduction, unlike in the wild where fish density is low and infections are usually mild. In a tank, C. irritans can wipe out an entire population.\nlife cycle The parasite\u0026rsquo;s life cycle is well documented. It includes four phases: [Colorni, 1987; Burgess \u0026amp; Matthews, 1994; Colorni \u0026amp; Burgess, 1997] :\nTrophont (on the fish, feeding).\nProtomont (leaves host and settles).\nTomont (encysted, dividing).\nTheront (free-swimming infective stage).\nThe trophont hides under the host\u0026rsquo;s mucus and epithelium, making it hard to treat or detect until symptoms appear.\nNot Just White Spots Fish respond differently depending on their skin, slime production, and type of scales.\nВаш браузер не поддерживает видео. Cryptocaryon. \u0026#39;gill\u0026#39; shape Fish respond differently depending on their skin, slime production, and type of scales. Cryptocaryon irritans has no teeth or appendages to penetrate thick skin. It lodges beneath the outer epithelial layer or between scale lining. In species with large, shield-like scales, cysts may form beneath them, staying undetected even after disinfection.\nThat’s why a fish may look healthy while still carrying viable cysts under its scales. [Zeng et al., 2023; Jee et al., 2001].\nDiagnosis: White Dots ≠ Diagnosis Scraping You need a skin scrape and microscopy. White spots can be anything: mucus clumps, food particles, air bubbles. Without confirmation, you risk misdiagnosing early disease — or treating when nothing’s wrong.\nResponse and Immunity Fish react differently. The immune response and mucus overproduction can worsen breathing, especially if gills are affected. Gas exchange depends on the mucus layer. If it thickens excessively, oxygen uptake drops [Gomez et al., 2013; Reverter et al., 2018].\nOften, when white specks appear on the skin, the gills are already heavily infected .\nStrains and Behavior There are multiple strains. Some mostly infect the skin and gill surfaces, causing limited tissue damage. Others invade deep into the gill epithelium, divide under tissue, and rupture cells from within. Often, when white specks appear on the skin, the gills are already heavily infected [Zeng et al., 2023; Cervera et al., 2022; Huang et al., 2023].\nDebunking Common Myths \u0026quot;This parasite exists in every tank\u0026quot;\nFalse. It must be introduced from outside. No cysts = no outbreak.\n\u0026quot;Stress causes crypto\u0026quot;\nFalse. Stress weakens immunity but doesn’t create the parasite.\n\u0026quot;White flakes = parasites\u0026quot;\nUsually it\u0026rsquo;s thickened immune mucus, not the parasite itself.\nWhy Nature Sees Fewer Outbreaks\nHuge water volumes dilute cysts. Wild fish are spread out, not crowded. ysts fall and disappear or are eaten by filter feeders. In a tank, even one surviving cyst can infect everyone. Treatment and Baths Freshwater dips — largely ineffective. Thick mucus protects parasites; fish suffer osmotically. [Huang et al., 2023; Jiang \u0026amp; Huang, 2023].\nChemical baths — may harm the fish more than the parasite. [Zahid et al., 2023].\nMalachite green — effective. It penetrates mucus and kills trophonts, but requires full treatment (1–2 weeks).\nCopper — useful, but needs precise dosing and timing.\nQuarantine - essential for new fish.\nDrying out tanks — leave fishless for a month or more. But if activation triggers are unknown, cysts may stay dormant and restart the cycle.\nUltraviolet and Ozone — Why They\u0026rsquo;re Not Magic Bullets Ultraviolet (UV) Yes, UV light kills pathogens — including parasites. But in reality:\nA UV sterilizer doesn\u0026rsquo;t eliminate all parasites in the aquarium by merely existing. For a parasite to be destroyed, it must pass through the UV chamber — where sufficient intensity and exposure time can do the job.\nHowever:\nParasites like Cryptocaryon irritans living on the fish are unaffected — they never enter the UV system.\nFree-swimming stages (theronts) move randomly; only a fraction will pass through the sterilizer.\nEncysted stages on substrate are completely untouched.\nIf C. irritans is reproducing within the gill epithelium (observed in some strains), UV has zero effect — the light can\u0026rsquo;t reach them.\nOzone Origin of Infection Ozone (O₃) is a powerful oxidizer, highly effective in water disinfection.\nIt can:\nDestroy bacteria, viruses, protozoans.\nClarify water by oxidizing organic particles.\nReduce biofilter load.\nImportant considerations: Effective parasite control requires an ORP of 300–500 mV.\nOzone is most effective in purified water. In natural or organically rich water, it may form toxic byproducts like bromates and aldehydes.\nResidual ozone is harmful to fish. Use carbon filters or degassing chambers to remove excess.\nBottom line: ozone can be incredibly effective — but only with precise control and understanding of water chemistry. Otherwise, it’s either ineffective or dangerous [Summerfelt, S. T., Wedemeyer, G. (1996)].\nREFERENCES Colorni A. Biology of Cryptocaryon irritans and strategies for its control. // Aquaculture. 1987. Т. 67. № 1/2. С. 236–237. Zeng S. и др. Effects of Cryptocaryon irritans infection on the histopathology, oxidative stress, immune response, and intestinal microbiota in the orange-spotted grouper Epinephelus coioides // Fish \u0026amp; Shellfish Immunology. 2023. Т. 133. С. 108562. Jee B. и др. A new strain of Cryptocaryon irritans from the cultured olive flounder Paralichthys olivaceus // Diseases of aquatic organisms. 2001. Т. 43. С. 211–5. Burgess P. J., Matthews R. A. Cryptocaryon irrttans (Ciliophora): photoperiod and transmission in marine fish // Journal of the Marine Biological Association of the United Kingdom. 1994. Т. 74. № 3. С. 535–542. Colorni A., Burgess P. Cryptocaryon irritans Brown 1951, the cause of ‘white spot disease’ in marine fish: an update // Aquarium Sciences and Conservation. 1997. Т. 1. С. 217–238. Brown E. A new parasitic protozoan, the causal organism of a white spot disease in marine fish Cryptocaryon irritans gen. and sp. n. (Agenda and abstr. Sci. Meet. , Zool. Soc. London, 1950). , 1951. Cervera L. и др. Severe Natural Outbreak of Cryptocaryon irritans in Gilthead Seabream Produces Leukocyte Mobilization and Innate Immunity at the Gill Tissue // Int J Mol Sci. 2022. Т. 23. № 2. С. 937. Cheung P. J., Nigrelli R. F., Ruggieri G. D. Studies on cryptocaryoniasis in marine fish: effect of temperature and salinity on the reproductive cycle of Cryptocaryon irritans Brown, 1951 // Journal of Fish Diseases. 1979. Т. 2. № 2. С. 93–97. Gomez D., Sunyer J. O., Salinas I. The mucosal immune system of fish: the evolution of tolerating commensals while fighting pathogens // Fish Shellfish Immunol. 2013. Т. 35. № 6. С. 1729–1739. Huang K. и др. Investigating the interplay between Cryptocaryon irritans ectoparasite infection and the immune responses of the head kidney in silver pomfret (Pampus argenteus) // Aquaculture. 2023. Т. 575. С. 739780. Jiang S., Huang X. Host responses against the fish parasitizing ciliate Cryptocaryon irritans // Parasite Immunology. 2023. Т. 45. № 3. С. e12967. Nigrelli R. F., Ruggieri G. D. Enzootics in the New York Aquarium caused by Cryptocaryon irritans Brown, 1951 (=Ichthyophthirius marinus Sikama, 1961), a histophagous ciliate in the skin, eyes and gills of marine fishes // Zoologica : scientific contributions of the New York Zoological Society. 1966. Т. 51. № 9. С. 97\u0026ndash;102. Summerfelt, S. T. (2003). Ozone applications in recirculating aquaculture systems. Wedemeyer, G. (1996). Physiology of Fish in Intensive Culture Systems Zahid A. и др. Antiparasitic effect of copper alloy mesh on tomont stage of Cryptocaryon irritans in aquaculture // Journal of Fish Diseases. 2023. Т. 46. № 3. С. 181–188. FAQ Do white spots always mean cryptocaryon? No. Similar signs may result from mucus, debris, or gas bubbles.\nWhy does fish suffocate without visible spots? Because gills may be affected without skin involvement.\nIs cryptocaryon always present in aquariums? No. It appears only after introduction.\nWhy do outbreaks escalate quickly? Because a single cyst can release many infective stages.\nCan diagnosis be made without microscopy? No. Visual signs alone are insufficient.\n","permalink":"https://fossamethod.ru/en/posts/crypt/","summary":"\u003cdiv id=\"CryptBlok\" class=\"toggleblock myth-reality\"\u003e\r\n    \u003cbutton class=\"toggle-btn\" onclick=\"toggleBlock('CryptBlok')\"\u003eToggle Myth / Reality\u003c/button\u003e\r\n    \u003cdiv class=\"toggle-content first\"\u003e\u003ch2 id=\"myth\"\u003eMyth\u003c/h2\u003e\n\u003chr\u003e\n\u003cblockquote\u003e\n\u003c/blockquote\u003e\n\u003ch3 id=\"description\"\u003eDescription:\u003c/h3\u003e\n\u003cblockquote\u003e\n\u003c/blockquote\u003e\n\u003cp\u003e\u0026ldquo;Crypt\u0026rdquo;, \u0026ldquo;marine ich\u0026rdquo;, or \u0026ldquo;white spot disease\u0026rdquo; — \u003cem\u003eCryptocaryon irritans\u003c/em\u003e is a ciliated protozoan parasite, often visible to the naked eye. Tangs, butterflyfish, and boxfish are particularly susceptible and typically among the first to become infected. The free-swimming infectious stage — theront — most often attaches to gills and fins. That’s why these areas should always be examined first.\u003c/p\u003e\n\u003cp\u003eOnce mature, the parasite detaches from the host and encysts on the substrate. Around day 3, the tomont undergoes uneven cell division. Between days 6–9, dozens to hundreds of theronts hatch and actively swim away in search of new hosts.\u003c/p\u003e","title":"Cryptocaryon irritans: Not Just White Spots"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/sagittaria_10x-cs/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Sagittaria_10x-cs.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Arrowhead (Sagittaria sp.)\",\n            description: \"Panoramic view of part of an aquarium arrowhead leaf. Numerous plant cells containing green chloroplasts, longitudinal veins, and a toothed leaf margin are visible. Zooming in reveals individual cell shapes, cell walls, and the arrangement of chloroplasts.\",\n            buttonImage: \"/dzi/images/Sagittaria_10x-cs.webp\",\n            dzi: \"Sagittaria_10x-cs.dzi\",\n            unit: \"mm\",\n            microns_per_pixel:  18.916237413562584 ,\n            image_microns_per_pixel:  0.8765361044623654 ,\n            calibration_unit: \"mm\",\n            roi_file: \"/annotations/Sagittaria_10x-cs.json\",\n            previewAlt: \"Part of an arrowhead leaf (Sagittaria sp.) showing cells with chloroplasts, longitudinal veins, and a toothed margin\",\n            pageUrl: \"/en/microscope-collection/sagittaria_10x-cs/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Arrowhead (Sagittaria sp.)"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/sagittaria_20x-sc/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Sagittaria_20x-sc.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Arrowhead (Sagittaria sp.) — 20×\",\n            description: \"Panoramic view of part of an aquarium arrowhead leaf. Numerous plant cells with distinct walls and green chloroplasts are clearly visible. The image shows individual cell shapes, chloroplasts arranged along the cell walls, and pale central regions occupied by large vacuoles.\",\n            buttonImage: \"/dzi/images/Sagittaria_20x-sc.webp\",\n            dzi: \"Sagittaria_20x-sc.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  4.872654402913997 ,\n            image_microns_per_pixel:  0.25327060142126057 ,\n            calibration_unit: \"µm\",\n            roi_file: \"/annotations/Sagittaria_20x-sc.json\",\n            previewAlt: \"Arrowhead leaf cells (Sagittaria sp.) with distinct cell walls and green chloroplasts\",\n            pageUrl: \"/en/microscope-collection/sagittaria_20x-sc/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Arrowhead (Sagittaria sp.) — 20×"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/sagittaria_pol_20x-sc/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Sagittaria_pol_20x-sc.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Arrowhead (Sagittaria sp.) — 20×, polarized light\",\n            description: \"Panoramic view of part of an aquarium arrowhead leaf in polarized light. Numerous plant cells, longitudinal veins, and pointed teeth along the leaf margin are visible. Polarized illumination produces golden tones and emphasizes cell boundaries, offering a different view of the leaf structure.\",\n            buttonImage: \"/dzi/images/Sagittaria_pol_20x-sc.webp\",\n            dzi: \"Sagittaria_pol_20x-sc.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  9.266613381675445 ,\n            image_microns_per_pixel:  0.50385553288289 ,\n            calibration_unit: \"µm\",\n            roi_file: \"/annotations/Sagittaria_pol_20x-sc.json\",\n            previewAlt: \"Arrowhead leaf (Sagittaria sp.) in polarized light, showing cells, longitudinal veins, and marginal teeth\",\n            pageUrl: \"/en/microscope-collection/sagittaria_pol_20x-sc/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Arrowhead (Sagittaria sp.) — 20×, polarized light"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/algaepano/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"algaePano.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Black beard algae\",\n            description: \"Red algae commonly found on aquarium plants...\",\n            buttonImage: \"/dzi/images/algaePano.webp\",\n            dzi: \"algaePano.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  0.9 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"\",\n            previewAlt: \"Filamentous red algae forming black beard algae growth in an aquarium\",\n            pageUrl: \"/en/microscope-collection/algaepano/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Black beard algae"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/audouinella_10x-sc_imagej/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Audouinella_10x-sc_imagej.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Black brush algae (presumably Audouinella) — 10×\",\n            description: \"General view of the bush-like thallus of a red alga, provisionally identified as Audouinella sp. The attachment region with rhizoids is visible at the top of the image. Zooming in reveals branching cellular filaments, transverse septa, and putative monosporangia.\",\n            buttonImage: \"/dzi/images/Audouinella_10x-sc_imagej.webp\",\n            dzi: \"Audouinella_10x-sc_imagej.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  5.5 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"/annotations/Audouinella_10x-sc_imagej.json\",\n            previewAlt: \"Bush-like thallus of a red alga, possibly Audouinella, showing branching filaments, 10×\",\n            pageUrl: \"/en/microscope-collection/audouinella_10x-sc_imagej/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Black brush algae (presumably Audouinella) — 10×"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/audouinella_20x-sc/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Audouinella_20x-sc.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Black brush algae (presumably Audouinella) — 20×\",\n            description: \"A branching network of multicellular filaments. The branching pattern, cellular segmentation, and rounded reproductive structures on short lateral branches are clearly visible.\",\n            buttonImage: \"/dzi/images/Audouinella_20x-sc.webp\",\n            dzi: \"Audouinella_20x-sc.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  4.1 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"/annotations/Audouinella_20x-sc.json\",\n            previewAlt: \"Branched red algal filaments with transverse septa and rounded lateral structures, 20×\",\n            pageUrl: \"/en/microscope-collection/audouinella_20x-sc/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Black brush algae (presumably Audouinella) — 20×"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/audouinella_40x-sc/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Audouinella_40x-sc.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Black brush algae (presumably Audouinella) — 40×\",\n            description: \"Detailed structure of the branching filaments of a red alga. Individual cells, transverse septa, and rounded structures on lateral branches, presumably monosporangia, are clearly visible.\",\n            buttonImage: \"/dzi/images/Audouinella_40x-sc.webp\",\n            dzi: \"Audouinella_40x-sc.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  3 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"/annotations/Audouinella_40x-sc.json\",\n            previewAlt: \"Branching cellular filaments of a red alga, possibly Audouinella, at 40× magnification\",\n            pageUrl: \"/en/microscope-collection/audouinella_40x-sc/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Black brush algae (presumably Audouinella) — 40×"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/bolbitis_40x_2/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Bolbitis_40x_2.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Bolbitis fern — leaf cells, 40×\",\n            description: \"Panoramic view of part of an aquarium Bolbitis fern leaf. Plant cells of different shapes containing numerous green chloroplasts are clearly visible. Zooming in reveals the cell walls, the arrangement of chloroplasts, and details of the leaf tissue structure.\",\n            buttonImage: \"/dzi/images/Bolbitis_40x_2.webp\",\n            dzi: \"Bolbitis_40x_2.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  5.638616473646889 ,\n            image_microns_per_pixel:  0.23899375162098732 ,\n            calibration_unit: \"µm\",\n            roi_file: \"/annotations/Bolbitis_40x_2.json\",\n            previewAlt: \"Bolbitis leaf cells with numerous green chloroplasts and visible cell walls\",\n            pageUrl: \"/en/microscope-collection/bolbitis_40x_2/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Bolbitis fern — leaf cells, 40×"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/bolbitis_10x_2/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Bolbitis_10x_2.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Bolbitis fern — leaf, 10×\",\n            description: \"Bolbitis fern leaf under a microscope, 10×: veins and polygonal cell outlines.\",\n            buttonImage: \"/dzi/images/Bolbitis_10x_2.webp\",\n            dzi: \"Bolbitis_10x_2.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  11.254374437526021 ,\n            image_microns_per_pixel:  0.6665163404207515 ,\n            calibration_unit: \"µm\",\n            roi_file: \"/annotations/Bolbitis_10x_2.json\",\n            previewAlt: \"Bolbitis fern leaf under a microscope, 10×: veins and polygonal cell outlines\",\n            pageUrl: \"/en/microscope-collection/bolbitis_10x_2/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Bolbitis fern — leaf, 10×"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/micopano/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"micoPano.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Branching filamentous bacteria — 100×\",\n            description: \"Spleen impression smear. Ziehl–Neelsen staining. 100× objective. Fuchsin-positive rod-shaped and filamentous structures showing prominent branching and uneven staining. The morphology is suggestive of branching actinomycetes, including Nocardia.\",\n            buttonImage: \"/dzi/images/micoPano.webp\",\n            dzi: \"micoPano.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  0.9 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"\",\n            previewAlt: \"Branching filamentous fuchsin-positive bacteria in a fish spleen smear, 100×\",\n            pageUrl: \"/en/microscope-collection/micopano/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Branching filamentous bacteria — 100×"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/mico2pano/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"mico2Pano.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Branching rod-shaped bacteria — 40×\",\n            description: \"Spleen impression smear. Ziehl–Neelsen staining. 40× objective. Fuchsin-positive rod-shaped and elongated structures showing apparent branching. The morphology is compatible with Nocardia or other actinomycetes.\",\n            buttonImage: \"/dzi/images/mico2Pano.webp\",\n            dzi: \"mico2Pano.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  3 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"/annotations/mico2Pano.json\",\n            previewAlt: \"Fuchsin-positive elongated and apparently branching bacteria in a fish spleen smear, 40×\",\n            pageUrl: \"/en/microscope-collection/mico2pano/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Branching rod-shaped bacteria — 40×"},{"content":"","permalink":"https://fossamethod.ru/en/video/buble/","summary":"","title":"Bubble formation"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/capsalidae_10x-sc/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Capsalidae_10x-sc.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Capsalid — internal structures in relief\",\n            description: \"A second panorama of the same specimen with more pronounced relief. The outlines and spatial relationships of the internal organs are more clearly visible, especially the reproductive structures, intestinal ceca, and structures of the posterior body region.\",\n            buttonImage: \"/dzi/images/Capsalidae_10x-sc.webp\",\n            dzi: \"Capsalidae_10x-sc.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  5 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"/annotations/Capsalidae_10x-sc.json\",\n            previewAlt: \"Whole-mount image of a capsalid monogenean with visible internal anatomical structures\",\n            pageUrl: \"/en/microscope-collection/capsalidae_10x-sc/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Capsalid — internal structures in relief"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/capsalidae_2_10x-sc/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Capsalidae_2_10x-sc.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Capsalid — whole mount\",\n            description: \"Panoramic whole-mount preparation of a capsalid monogenean. The pharynx, intestinal ceca, vitellaria, ovary, testes, and posterior attachment organ — the haptor — are clearly visible.\",\n            buttonImage: \"/dzi/images/Capsalidae_2_10x-sc.webp\",\n            dzi: \"Capsalidae_2_10x-sc.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  6 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"/annotations/Capsalidae_2_10x-sc.json\",\n            previewAlt: \"Capsalid monogenean under a microscope: body, internal organs and posterior attachment organ\",\n            pageUrl: \"/en/microscope-collection/capsalidae_2_10x-sc/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Capsalid — whole mount"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/chromis/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Chromis.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Chromis\",\n            description: \"Scales of the fish Chromis viridis.\",\n            buttonImage: \"/dzi/images/Chromis.webp\",\n            dzi: \"Chromis.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  6 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"\",\n            previewAlt: \"Microscopy preparation of scales from Chromis viridis\",\n            pageUrl: \"/en/microscope-collection/chromis/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Chromis"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/keta_kidney_4x-sc/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Keta_kidney_4x-sc.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Chum salmon kidney — relatively preserved structure\",\n            description: \"Panoramic compression preparation of the kidney from a clinically healthy chum salmon after euthanasia. The renal tubules retain their usual structure and relatively clear lumina, while blood is distributed comparatively evenly throughout the tissue. The specimen serves as a control for comparison with pathological tubular changes.\",\n            buttonImage: \"/dzi/images/Keta_kidney_4x-sc.webp\",\n            dzi: \"Keta_kidney_4x-sc.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  17 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"/annotations/Keta_kidney_4x-sc.json\",\n            previewAlt: \"Chum salmon kidney squash preparation with relatively preserved renal tubules and lumina\",\n            pageUrl: \"/en/microscope-collection/keta_kidney_4x-sc/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Chum salmon kidney — relatively preserved structure"},{"content":"","permalink":"https://fossamethod.ru/en/video/ciliated-epithelium/","summary":"","title":"Ciliated Epithelium of the Kidney"},{"content":"","permalink":"https://fossamethod.ru/en/video/ciliate-and-bacter/","summary":"","title":"Ciliates and Bacteria on Fish Surfaces"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/amphiprion_black_3mm-sc/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Amphiprion_black_3mm-sc.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Clownfish larva (Amphiprion sp.) — dark-field illumination\",\n            description: \"Panoramic view of a clownfish larva approximately 3 mm long. Its transparent body reveals internal structures, large eyes, the vertebral column, pigment cells, and developing fins.\",\n            buttonImage: \"/dzi/images/Amphiprion_black_3mm-sc.webp\",\n            dzi: \"Amphiprion_black_3mm-sc.dzi\",\n            unit: \"mm\",\n            microns_per_pixel:  4.980983308888304 ,\n            image_microns_per_pixel:  0.4040100778575707 ,\n            calibration_unit: \"mm\",\n            roi_file: \"/annotations/Amphiprion_black_3mm-sc.json\",\n            previewAlt: \"Transparent clownfish larva (Amphiprion sp.), approximately 3 mm long, in dark-field illumination\",\n            pageUrl: \"/en/microscope-collection/amphiprion_black_3mm-sc/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Clownfish larva (Amphiprion sp.) — dark-field illumination"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/amphiprion_pol_sc-3mm/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Amphiprion_pol_sc-3mm.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Clownfish larva (Amphiprion sp.) — polarized light\",\n            description: \"Panoramic view of a clownfish larva approximately 3 mm long. Its transparent body reveals internal structures, large eyes, the vertebral column, pigment cells, and developing fins. Polarized light emphasizes tissue structure and produces distinctive colors.\",\n            buttonImage: \"/dzi/images/Amphiprion_pol_sc-3mm.webp\",\n            dzi: \"Amphiprion_pol_sc-3mm.dzi\",\n            unit: \"mm\",\n            microns_per_pixel:  4.964314679637671 ,\n            image_microns_per_pixel:  0.4476957313073557 ,\n            calibration_unit: \"mm\",\n            roi_file: \"/annotations/Amphiprion_pol_sc-3mm.json\",\n            previewAlt: \"Clownfish larva (Amphiprion sp.), approximately 3 mm long, in polarized light\",\n            pageUrl: \"/en/microscope-collection/amphiprion_pol_sc-3mm/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Clownfish larva (Amphiprion sp.) — polarized light"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/kokki/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Kokki.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Cocci\",\n            description: \"Coccoid bacteria.\",\n            buttonImage: \"/dzi/images/Kokki.webp\",\n            dzi: \"Kokki.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  0.63 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"/annotations/Kokki.json\",\n            previewAlt: \"Coccoid bacteria in a microscopy preparation\",\n            pageUrl: \"/en/microscope-collection/kokki/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Cocci"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/gills_ciprinus-sc/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Gills_ciprinus-sc.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Common carp (Cyprinus carpio) — gills\",\n            description: \"Gill filaments with numerous transverse lamellae, the principal sites of gas exchange, are clearly visible. Zooming in reveals the thin walls of the lamellae, blood capillaries, and blood cells within them.\",\n            buttonImage: \"/dzi/images/Gills_ciprinus-sc.webp\",\n            dzi: \"Gills_ciprinus-sc.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  2.233662263419819 ,\n            image_microns_per_pixel:  0.12827936343190993 ,\n            calibration_unit: \"µm\",\n            roi_file: \"/annotations/Gills_ciprinus-sc.json\",\n            previewAlt: \"Gill filaments and secondary lamellae of common carp (Cyprinus carpio) under a microscope\",\n            pageUrl: \"/en/microscope-collection/gills_ciprinus-sc/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Common carp (Cyprinus carpio) — gills"},{"content":"","permalink":"https://fossamethod.ru/en/video/cryptobia-run/","summary":"","title":"Cryptobia Moving Through Detritus"},{"content":"","permalink":"https://fossamethod.ru/en/video/cryptocaryon/","summary":"","title":"Cryptocaryon irritans in gills"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/cryptopano/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"cryptoPano.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Cryptosporidia 100x\",\n            description: \"Danio liver smear. May–Grünwald stain. Objective 100x.\",\n            buttonImage: \"/dzi/images/cryptoPano.webp\",\n            dzi: \"cryptoPano.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  0.34 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"/annotations/cryptoPano.json\",\n            previewAlt: \"May–Grünwald-stained zebrafish liver smear with suspected parasitic structures, 100×\",\n            pageUrl: \"/en/microscope-collection/cryptopano/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Cryptosporidia 100x"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/crypto2pano/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"crypto2Pano.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Cryptosporidia 100x (ZN)\",\n            description: \"Danio liver smear. Ziehl–Neelsen stain. Objective 100x.\",\n            buttonImage: \"/dzi/images/crypto2Pano.webp\",\n            dzi: \"crypto2Pano.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  0.34 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"/annotations/crypto2Pano.json\",\n            previewAlt: \"Ziehl–Neelsen-stained zebrafish liver smear with suspected parasitic structures, 100×\",\n            pageUrl: \"/en/microscope-collection/crypto2pano/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Cryptosporidia 100x (ZN)"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/gills_damage/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Gills_damage.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Degenerated Gills of a Dead Fish\",\n            description: \"Even markedly postmortem-altered gills may retain diagnostically relevant findings. Attached monogeneans can still be detected, helping to reveal potential parasitic threats and indicating what should be looked for in living fish.\",\n            buttonImage: \"/dzi/images/Gills_damage.webp\",\n            dzi: \"Gills_damage.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  20 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"/annotations/Gills_damage.json\",\n            previewAlt: \"Postmortem-altered fish gills with attached monogenean parasites in a microscopy preparation\",\n            pageUrl: \"/en/microscope-collection/gills_damage/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Degenerated Gills of a Dead Fish"},{"content":"Tip: Use Ctrl + Mouse Wheel to adjust the page zoom. Choose the zoom level that is most comfortable for you.\n","permalink":"https://fossamethod.ru/en/test/reasoning-test/","summary":"An interactive reasoning trainer: observations, conclusions, and the limits of evidence.","title":"Diagnostic Thinking"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/diatoms_braun_40x-sc/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Diatoms_Braun_40x-sc.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Diatoms from a Marine Aquarium\",\n            description: \"Microscopic panorama of a brown film collected from the glass of a marine aquarium. Numerous diatoms of different shapes, sizes, and structures are visible. Most have elongated or oval cells. Their golden-brown chloroplasts are enclosed within transparent silica shells, which display fine lines and intricate patterns.\",\n            buttonImage: \"/dzi/images/Diatoms_Braun_40x-sc.webp\",\n            dzi: \"Diatoms_Braun_40x-sc.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  1.411026614392012 ,\n            image_microns_per_pixel:  0.09243155463620088 ,\n            calibration_unit: \"µm\",\n            roi_file: \"/annotations/Diatoms_Braun_40x-sc.json\",\n            previewAlt: \"Numerous golden-brown diatoms of various shapes and sizes, showing transparent silica shells with fine surface patterns.\",\n            pageUrl: \"/en/microscope-collection/diatoms_braun_40x-sc/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Diatoms from a Marine Aquarium"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/discus/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Discus.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Discus\",\n            description: \"Scales of the fish Discus.\",\n            buttonImage: \"/dzi/images/Discus.webp\",\n            dzi: \"Discus.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  4 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"\",\n            previewAlt: \"Microscopy preparation of discus fish scales\",\n            pageUrl: \"/en/microscope-collection/discus/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Discus"},{"content":"","permalink":"https://fossamethod.ru/en/video/ichthyophthirius/","summary":"","title":"Division of Ichthyophthirius multifiliis"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/pano_20261028_122120/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"PANO_20261028_122120.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Duckweed — dark-field illumination\",\n            description: \"Panoramic view of the small green fronds of duckweed, one of the smallest flowering plants. Their rounded outlines, numerous cells, and paler tissue regions are visible. Duckweed floats freely on the water surface and can multiply rapidly by producing daughter plants.\",\n            buttonImage: \"/dzi/images/PANO_20261028_122120.webp\",\n            dzi: \"PANO_20261028_122120.dzi\",\n            unit: \"mm\",\n            microns_per_pixel:  9.397577162957717 ,\n            image_microns_per_pixel:  0.5726761485434831 ,\n            calibration_unit: \"mm\",\n            roi_file: \"/annotations/PANO_20261028_122120.json\",\n            previewAlt: \"Rounded green duckweed fronds in dark-field illumination, showing parent and daughter plants\",\n            pageUrl: \"/en/microscope-collection/pano_20261028_122120/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Duckweed — dark-field illumination"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/marine_fouling_algae/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Marine_fouling_algae.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Feather-like Green Algae from a Marine Aquarium\",\n            description: \"Microscopic panorama of green algal growth from a marine aquarium, tentatively identified as Bryopsis. Delicate branching filaments form structures resembling tiny fir trees or feathers. Numerous green lateral branchlets extend from a central axis. A distinctive feature of these algae is their siphonous organization, without the usual transverse cell partitions.\",\n            buttonImage: \"/dzi/images/Marine_fouling_algae.webp\",\n            dzi: \"Marine_fouling_algae.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  6.4072599558884775 ,\n            image_microns_per_pixel:  1.4350074155654506 ,\n            calibration_unit: \"µm\",\n            roi_file: \"/annotations/Marine_fouling_algae.json\",\n            previewAlt: \"Feather-like branching thallus of a green marine alga, showing a central axis with numerous elongated lateral branchlets against a black background.\",\n            pageUrl: \"/en/microscope-collection/marine_fouling_algae/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Feather-like Green Algae from a Marine Aquarium"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/fibrosus_peskar_10x-sc/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Fibrosus_Peskar_10x-sc.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Fibrous granulomas in gudgeon\",\n            description: \"Squash preparation of gudgeon (Gobio gobio) tissue. Multiple rounded structures of varying sizes with concentric arrangements of connective tissue fibers, consistent with fibrous granulomas.\",\n            buttonImage: \"/dzi/images/Fibrosus_Peskar_10x-sc.webp\",\n            dzi: \"Fibrosus_Peskar_10x-sc.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  8 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"/annotations/Fibrosus_Peskar_10x-sc.json\",\n            previewAlt: \"Squash preparation of gudgeon tissue with multiple rounded fibrous nodular structures\",\n            pageUrl: \"/en/microscope-collection/fibrosus_peskar_10x-sc/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Fibrous granulomas in gudgeon"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/filamentous_bacteria_2-sc/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Filamentous_Bacteria_2-sc.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Filamentous Bacteria in a Fish Gill Smear\",\n            description: \"Microscopic panorama of a fish gill smear stained with May–Grünwald stain. Numerous thin filamentous and rod-shaped structures are visible, occasionally forming dense aggregates. Their morphology resembles bacteria associated with columnaris-like gill lesions. The microorganisms have not been identified to species level.\",\n            buttonImage: \"/dzi/images/Filamentous_Bacteria_2-sc.webp\",\n            dzi: \"Filamentous_Bacteria_2-sc.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  1.5214225799747558 ,\n            image_microns_per_pixel:  0.10076452377017524 ,\n            calibration_unit: \"µm\",\n            roi_file: \"/annotations/Filamentous_Bacteria_2-sc.json\",\n            previewAlt: \"May–Grünwald-stained fish gill smear showing numerous thin blue filaments, rod-shaped structures, and aggregates of stained cellular material.\",\n            pageUrl: \"/en/microscope-collection/filamentous_bacteria_2-sc/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Filamentous Bacteria in a Fish Gill Smear"},{"content":"","permalink":"https://fossamethod.ru/en/video/fin-erosion/","summary":"","title":"Fin ray structure"},{"content":"","permalink":"https://fossamethod.ru/en/video/autopsy/","summary":"","title":"Fish necropsy"},{"content":"","permalink":"https://fossamethod.ru/en/video/fungi-in-fish/","summary":"","title":"Fungal Hyphae in Fish Tissues"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/fungal_structures_40x/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Fungal_structures_40x.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Fungal structures\",\n            description: \"A preparation of mucus and contents from the empty stomach of a black ghost knifefish (Apteronotus albifrons). Numerous filamentous fungal structures are visible among mucus, detritus, and small rounded elements. This finding indicates a marked presence of fungal forms in the gastric lumen and is pathologically significant. Captured with a 40× objective.\",\n            buttonImage: \"/dzi/images/Fungal_structures_40x.webp\",\n            dzi: \"Fungal_structures_40x.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  3 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"\",\n            previewAlt: \"Filamentous fungal structures among mucus and stomach contents of a black ghost knifefish, 40×\",\n            pageUrl: \"/en/microscope-collection/fungal_structures_40x/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Fungal structures"},{"content":"","permalink":"https://fossamethod.ru/en/video/fungi-native/","summary":"","title":"Fungal Structures in a Native Preparation"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/gadus/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Gadus.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Gadus\",\n            description: \"Scales of the fish Gadus.\",\n            buttonImage: \"/dzi/images/Gadus.webp\",\n            dzi: \"Gadus.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  3.5 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"\",\n            previewAlt: \"Microscopy preparation of pollock fish scales\",\n            pageUrl: \"/en/microscope-collection/gadus/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Gadus"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/jillsnecrozpano/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"jillsNecrozPano.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Gills\",\n            description: \"Necrosis of gill lamellae.\",\n            buttonImage: \"/dzi/images/jillsNecrozPano.webp\",\n            dzi: \"jillsNecrozPano.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  10 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"\",\n            previewAlt: \"Fish gill microscopy preparation showing damaged and necrotic gill lamellae\",\n            pageUrl: \"/en/microscope-collection/jillsnecrozpano/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Gills"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/kidney_scalare_20x/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Kidney_scalare_20x.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Granulomas in the Kidney of a Freshwater Angelfish\",\n            description: \"Microscopic panorama of kidney tissue from a freshwater angelfish (Pterophyllum scalare) showing granulomatous lesions. Areas of altered cellular material and darkly stained inclusions are visible among the renal structures. Acid-fast bacteria were detected during examination, suggesting a possible mycobacterial origin of the lesions. The bacterial species has not been identified.\",\n            buttonImage: \"/dzi/images/Kidney_scalare_20x.webp\",\n            dzi: \"Kidney_scalare_20x.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  14.201373370652101 ,\n            image_microns_per_pixel:  0.5928379483333229 ,\n            calibration_unit: \"µm\",\n            roi_file: \"/annotations/Kidney_scalare_20x.json\",\n            previewAlt: \"Microscopic panorama of freshwater angelfish kidney tissue showing granulomatous lesions, dark aggregates of material, and surrounding renal structures.\",\n            pageUrl: \"/en/microscope-collection/kidney_scalare_20x/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Granulomas in the Kidney of a Freshwater Angelfish"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/seaweed_20x-sc/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"seaweed_20X-sc.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Green Algal Growth in a Marine Aquarium\",\n            description: \"Algal growth collected from the outer surface of a water supply pipe in a marine aquarium. Under the microscope, long green filaments are visible among numerous golden-brown diatoms. These diatoms vary in shape and size, forming a diverse underwater community together with the filamentous algae.\",\n            buttonImage: \"/dzi/images/seaweed_20X-sc.webp\",\n            dzi: \"seaweed_20X-sc.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  6.808220644802301 ,\n            image_microns_per_pixel:  0.2484386941799429 ,\n            calibration_unit: \"µm\",\n            roi_file: \"/annotations/seaweed_20X-sc.json\",\n            previewAlt: \"Microscopic panorama of green filamentous growth with numerous golden-brown diatoms of various shapes.\",\n            pageUrl: \"/en/microscope-collection/seaweed_20x-sc/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Green Algal Growth in a Marine Aquarium"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/green_algal-sc/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Green_algal-sc.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Green Microalgae on Freshwater Aquarium Glass\",\n            description: \"Microscopic panorama of green algal growth collected from the glass of a freshwater aquarium. To the naked eye, these algae appear as small green spots firmly attached to the glass. Under the microscope, numerous rounded cells form dense clusters. Green chloroplasts responsible for photosynthesis are visible inside the cells.\",\n            buttonImage: \"/dzi/images/Green_algal-sc.webp\",\n            dzi: \"Green_algal-sc.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  0.6086160498769677 ,\n            image_microns_per_pixel:  0.04461994500564279 ,\n            calibration_unit: \"µm\",\n            roi_file: \"/annotations/Green_algal-sc.json\",\n            previewAlt: \"Dense cluster of rounded green microalgal cells with visible cell boundaries and green internal structures.\",\n            pageUrl: \"/en/microscope-collection/green_algal-sc/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Green Microalgae on Freshwater Aquarium Glass"},{"content":"","permalink":"https://fossamethod.ru/en/video/heat-fish/","summary":"","title":"Heart of an Amur Sleeper Larva Under the Microscope"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/yeast_like_fungal_cells_100/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"yeast_like_fungal_cells_100.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Hyphal and sporangial structures\",\n            description: \"A high-magnification May–Grünwald-stained preparation of intestinal contents. Hyphal structures and rounded sporangial forms are visible among mucus and fragments of food material. Together with the massive presence of yeast-like cells in the gastric contents, this finding indicates marked fungal involvement of the digestive tract. Captured with a 100× objective.\",\n            buttonImage: \"/dzi/images/yeast_like_fungal_cells_100.webp\",\n            dzi: \"yeast_like_fungal_cells_100.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  1.2 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"\",\n            previewAlt: \"Hyphal and rounded structures in a May–Grünwald-stained preparation of intestinal contents, 100×\",\n            pageUrl: \"/en/microscope-collection/yeast_like_fungal_cells_100/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Hyphal and sporangial structures"},{"content":"","permalink":"https://fossamethod.ru/en/video/ichtiobodo/","summary":"","title":"Ichthyobodo spp.: Comparing Morphotypes"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/gistopano/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"gistoPano.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Intracellular parasites 100x\",\n            description: \"Chrysiptera liver smear 100x. May–Grünwald stain. Parasites in histiocytes.\",\n            buttonImage: \"/dzi/images/gistoPano.webp\",\n            dzi: \"gistoPano.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  1.5 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"\",\n            previewAlt: \"Chromis liver smear with suspected intracellular parasites in histiocytes, 100×\",\n            pageUrl: \"/en/microscope-collection/gistopano/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Intracellular parasites 100x"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/labidochromis/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Labidochromis.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Labidochromis\",\n            description: \"Scales of the fish Labidochromis yellow.\",\n            buttonImage: \"/dzi/images/Labidochromis.webp\",\n            dzi: \"Labidochromis.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  8.5 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"\",\n            previewAlt: \"Microscopy preparation of Labidochromis cichlid scales\",\n            pageUrl: \"/en/microscope-collection/labidochromis/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Labidochromis"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/fouling_10x-sc/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"fouling_10x-sc.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Leaf-like Brown Algae from a Marine Aquarium\",\n            description: \"Small leaf-like growths collected from the wall of a tropical marine aquarium. Under the microscope, thin brown blades composed of numerous cells are visible. The cells form rows that spread out in fan-shaped patterns. Unlike filamentous algae, these algae form broad thalli resembling tiny leaves.\",\n            buttonImage: \"/dzi/images/fouling_10x-sc.webp\",\n            dzi: \"fouling_10x-sc.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  12.315279164747666 ,\n            image_microns_per_pixel:  0.5591849495195526 ,\n            calibration_unit: \"µm\",\n            roi_file: \"/annotations/fouling_10x-sc.json\",\n            previewAlt: \"Microscopic panorama of a brown, blade-like algal thallus with fan-shaped rows of cells and irregular margins.\",\n            pageUrl: \"/en/microscope-collection/fouling_10x-sc/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Leaf-like Brown Algae from a Marine Aquarium"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/granulomaapteronotus/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"GranulomaApteronotus.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Liver of Apteronotus albifrons with granulomatous lesions\",\n            description: \"A squash preparation from the intestine of Apteronotus albifrons. Multiple granulomatous lesions associated with a mycobacterial infection are visible among mucus and sloughed mucosal material. However, the etiology of such lesions cannot be determined from morphology alone without additional investigations.\",\n            buttonImage: \"/dzi/images/Granuloma_Apteronotus.webp\",\n            dzi: \"GranulomaApteronotus.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  7 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"/annotations/GranulomaApteronotus.json\",\n            previewAlt: \"Microscopy preparation of Apteronotus albifrons tissue with multiple granulomatous lesions\",\n            pageUrl: \"/en/microscope-collection/granulomaapteronotus/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Liver of Apteronotus albifrons with granulomatous lesions"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/liver_lipid_10x/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Liver_lipid_10x.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Liver with lipid inclusions\",\n            description: \"A squash preparation of the liver of a neon tetra (Paracheirodon innesi). Numerous rounded lipid inclusions, uneven tissue coloration, and areas of marked blood filling are visible. This pattern reflects severe hepatic alteration and should be interpreted together with other findings. Captured with a 10× objective.\",\n            buttonImage: \"/dzi/images/Liver_lipid_10x.webp\",\n            dzi: \"Liver_lipid_10x.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  7 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"\",\n            previewAlt: \"Neon tetra liver squash preparation with numerous rounded lipid inclusions, 10×\",\n            pageUrl: \"/en/microscope-collection/liver_lipid_10x/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Liver with lipid inclusions"},{"content":"","permalink":"https://fossamethod.ru/en/video/ziehl/","summary":"","title":"Loeffler vs Ziehl–Neelsen"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/nematodpano/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"nematodPano.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Microworms\",\n            description: \"Microworms in the brain membrane of a ray, 20x. Small nematodes.\",\n            buttonImage: \"/dzi/images/nematodPano.webp\",\n            dzi: \"nematodPano.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  5 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"\",\n            previewAlt: \"Small nematodes in a ray meningeal preparation, 20× objective\",\n            pageUrl: \"/en/microscope-collection/nematodpano/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Microworms"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/miki_without_acid_40x/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"miki_without_acid_40x.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Modified carbol fuchsin staining without acid decolorization\",\n            description: \"Intensely stained red-pink rod-shaped bacteria are visible in the tissue material against a contrasting background. Acid decolorization was not performed, so acid-fastness was not assessed. Try to find them all...\",\n            buttonImage: \"/dzi/images/miki_without_acid_40x.webp\",\n            dzi: \"miki_without_acid_40x.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  1.25 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"/annotations/miki_without_acid_40x.json\",\n            previewAlt: \"Red-pink rod-shaped bacteria stained with fuchsin without acid decolorization\",\n            pageUrl: \"/en/microscope-collection/miki_without_acid_40x/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Modified carbol fuchsin staining without acid decolorization"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/monodactil/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"monodactil.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Monodactyl's Tail\",\n            description: \"The caudal fin of a Monodactylus. Note the soft tissue and ray segments.\",\n            buttonImage: \"/dzi/images/monodactil.webp\",\n            dzi: \"monodactil.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  25 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"\",\n            previewAlt: \"Monodactylus caudal fin under a microscope, showing soft tissue and segmented fin rays\",\n            pageUrl: \"/en/microscope-collection/monodactil/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Monodactyl's Tail"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/monodactylus/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Monodactylus.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Monodactylus\",\n            description: \"Scales of the fish Monodactylus.\",\n            buttonImage: \"/dzi/images/Monodactylus.webp\",\n            dzi: \"Monodactylus.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  4.5 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"\",\n            previewAlt: \"Monodactylus fish scales under a microscope\",\n            pageUrl: \"/en/microscope-collection/monodactylus/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Monodactylus"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/eggsnematpano/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"eggsNematPano.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Nematode eggs\",\n            description: \"Capillaria eggs from Danio intestine.\",\n            buttonImage: \"/dzi/images/eggsNematPano.webp\",\n            dzi: \"eggsNematPano.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  1.6 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"\",\n            previewAlt: \"Nematode eggs, possibly capillariids, from zebrafish intestine under a microscope\",\n            pageUrl: \"/en/microscope-collection/eggsnematpano/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Nematode eggs"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/gills_coregonus/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Gills_Coregonus.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Omul (Coregonus sp.) — gill anatomy\",\n            description: \"Panoramic preparation of the gill apparatus of an omul (Coregonus sp.). The gill arch, numerous gill filaments (primary lamellae), and secondary gill lamellae are visible. At higher magnification, the regularly arranged secondary lamellae can be clearly distinguished; they provide the principal surface for gas exchange.\",\n            buttonImage: \"/dzi/images/Gills_Coregonus.webp\",\n            dzi: \"Gills_Coregonus.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  14.393876010418436 ,\n            image_microns_per_pixel:  1.3796461451459918 ,\n            calibration_unit: \"\",\n            roi_file: \"/annotations/Gills_Coregonus.json\",\n            previewAlt: \"Microscopic view of omul (Coregonus sp.) gills showing the gill arch, primary gill filaments, and numerous secondary gill lamellae.\",\n            pageUrl: \"/en/microscope-collection/gills_coregonus/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Omul (Coregonus sp.) — gill anatomy"},{"content":"","permalink":"https://fossamethod.ru/en/video/color/","summary":"","title":"Pigment or Cocci?"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/mold/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Mold.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Pigmented fungal structures on crab gills\",\n            description: \"Panorama fragment of crab gills showing branching septate hyphae and numerous pigmented rounded structures. Macroscopically, affected areas of the gills were black and showed tissue destruction.\",\n            buttonImage: \"/dzi/images/Mold.webp\",\n            dzi: \"Mold.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  3 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"\",\n            previewAlt: \"Crab gills with branching pigmented fungal hyphae and rounded structures\",\n            pageUrl: \"/en/microscope-collection/mold/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Pigmented fungal structures on crab gills"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/pleurogrammus/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Pleurogrammus.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Pleurogrammus\",\n            description: \"Scales of the fish Pleurogrammus.\",\n            buttonImage: \"/dzi/images/Pleurogrammus.webp\",\n            dzi: \"Pleurogrammus.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  5 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"\",\n            previewAlt: \"Microscopy preparation of Pleurogrammus greenling scales\",\n            pageUrl: \"/en/microscope-collection/pleurogrammus/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Pleurogrammus"},{"content":"","permalink":"https://fossamethod.ru/en/video/praziquantel/","summary":"","title":"Praziquantel in Water"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/pterophyllum/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Pterophyllum.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Pterophyllum\",\n            description: \"Scales of the fish Pterophyllum scalare.\",\n            buttonImage: \"/dzi/images/Pterophyllum.webp\",\n            dzi: \"Pterophyllum.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  3 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"\",\n            previewAlt: \"Pterophyllum scalare angelfish scales under a microscope\",\n            pageUrl: \"/en/microscope-collection/pterophyllum/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Pterophyllum"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/blood_stingray/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Blood_stingray.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Ray Blood Cells\",\n            description: \"Microscopic panorama of a stained ray blood smear. Most cells are oval, nucleated erythrocytes. Various leukocytes are also present, including eosinophilic granulocytes and large cells with abundant cytoplasm. The panorama allows comparison of the shapes, sizes, and structural features of different blood cells.\\n\",\n            buttonImage: \"/dzi/images/Blood_stingray.webp\",\n            dzi: \"Blood_stingray.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  1.5932511405836862 ,\n            image_microns_per_pixel:  0.09662119853272712 ,\n            calibration_unit: \"µm\",\n            roi_file: \"/annotations/Blood_stingray.json\",\n            previewAlt: \"Microscopic panorama of ray blood showing numerous nucleated erythrocytes and leukocytes of different shapes and sizes.\",\n            pageUrl: \"/en/microscope-collection/blood_stingray/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Ray Blood Cells"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/kidney_neon_granulema_%D1%81ontrast-sc/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Kidney_neon_granulema_сontrast-sc.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Renal concretions in neon tetra\",\n            description: \"Microscopic preparation of neon tetra kidney. Rounded and oval structures of varying sizes with distinct boundaries and heterogeneous contents, presumably mineral concretions. Some are surrounded by cellular structures resembling a granulomatous reaction. No mycobacteria were detected, and similar lesions were not observed in other organs.\",\n            buttonImage: \"/dzi/images/Kidney_neon_granulema_сontrast-sc.webp\",\n            dzi: \"Kidney_neon_granulema_сontrast-sc.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  8 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"/annotations/Kidney_neon_granulema_сontrast-sc.json\",\n            previewAlt: \"Neon tetra kidney preparation with rounded structures of various sizes, possibly concretions\",\n            pageUrl: \"/en/microscope-collection/kidney_neon_granulema_%D1%81ontrast-sc/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Renal concretions in neon tetra"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/secret/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Secret.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Secret\",\n            description: \"What?\",\n            buttonImage: \"/dzi/images/Secret.webp\",\n            dzi: \"Secret.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  1.2 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"\",\n            previewAlt: \"Microscopy specimen from the Secret collection, intended for independent exploration\",\n            pageUrl: \"/en/microscope-collection/secret/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Secret"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/mikism/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"MikiSm.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Thin fuchsin-positive bacteria\",\n            description: \"Impression smear. Ziehl–Neelsen staining. Numerous slender rod-shaped bacteria are observed among cellular elements. Morphological features alone do not allow identification at the genus level.\",\n            buttonImage: \"/dzi/images/MikiSm.webp\",\n            dzi: \"MikiSm.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  1.6 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"/annotations/MikiSm.json\",\n            previewAlt: \"Numerous slender fuchsin-positive rod-shaped bacteria among cellular elements in a smear\",\n            pageUrl: \"/en/microscope-collection/mikism/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Thin fuchsin-positive bacteria"},{"content":"","permalink":"https://fossamethod.ru/en/video/hexamitids/","summary":"","title":"What 'many hexamitids' actually looks like"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/yeast_like_fungal_cells_40/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"yeast_like_fungal_cells_40.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Yeast-like structures\",\n            description: \"A May–Grünwald-stained preparation of gastric contents from a neon tetra (Paracheirodon innesi). Numerous rounded pink-purple structures with a clear capsule-like halo are visible. Morphologically, they are consistent with yeast-like fungal cells mixed with food material. Captured with a 40× objective.\",\n            buttonImage: \"/dzi/images/yeast_like_fungal_cells_40.webp\",\n            dzi: \"yeast_like_fungal_cells_40.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  3 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"/annotations/yeast_like_fungal_cells_40.json\",\n            previewAlt: \"Rounded pink-purple yeast-like structures in neon tetra stomach contents, 40×\",\n            pageUrl: \"/en/microscope-collection/yeast_like_fungal_cells_40/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Yeast-like structures"},{"content":" Brightness 100% Contrast 100% — Loading image… ⛶Fullscreen Capture Annotations: Off ","permalink":"https://fossamethod.ru/en/microscope-collection/kidney_1-sc/","summary":"\u003cstyle\u003e\n \n.microscope-collection {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n    --specimen-card-bg: color-mix(in srgb, var(--entry, #ffffff) 90%, var(--secondary, #777777) 10%);\n    --specimen-preview-bg: color-mix(in srgb, var(--theme, #ffffff) 92%, var(--secondary, #777777) 8%);\n    --specimen-border: var(--border, #d8d8d8);\n    --specimen-fg: var(--primary, #222222);\n    --specimen-accent: #da695d;\n    --scope-control-axis: 26px;  \n}\n\n.scope-container {\n    width: 700px;\n    height: auto;\n    margin: 5px auto 50px auto;\n    position: relative;\n    min-height: 700px; \n}\n\n.specimen-info {\n    text-align: center;\n    margin-bottom: 20px;\n    padding: 0;\n}\n\n.specimen-name {\n    font-size: 24px;\n    font-weight: bold;\n    margin-bottom: 10px;\n}\n\n.specimen-description {\n    line-height: 1.6;\n    font-size: 16px;\n    max-width: 600px;\n    margin: 0 auto;\n}\n\n.collection-controls {\n    display: flex;\n    flex-direction: column;\n    gap: 10px;\n}\n\n.collection-title {\n    text-align: center;\n    margin: 0;\n    padding-top: 5px;\n}\n\n.annotation-toggle-btn {\n    margin: 0 auto;\n    padding: 8px 14px;\n    border-radius: 8px;\n    cursor: pointer;\n}\n\n.buttons-scroll-container {\n    max-height: 800px;\n    overflow-y: auto;\n    overflow-x: hidden;\n     \n    -webkit-overflow-scrolling: touch;\n    touch-action: pan-y;\n    padding: 5px 5px 14px;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: transparent;\n    scrollbar-width: thin;\n    scrollbar-color: var(--tertiary, #aaa) transparent;\n}\n\n.collection-buttons {\n    display: grid;\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    gap: 14px;\n    align-items: stretch;\n}\n\n \n.microscope-collection .fossa-specimen-card {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n}\n\n.microscope-collection .fossa-specimen-card \u003e .specimen-btn {\n    height: auto;\n    flex: 1;\n}\n\n.microscope-collection .fossa-specimen-page-link {\n    display: block;\n    text-align: center;\n    padding: 5px 4px 7px;\n    color: var(--secondary, #777);\n    font-size: 11px;\n    line-height: 1.35;\n    text-decoration: underline;\n    text-underline-offset: 3px;\n    overflow-wrap: anywhere;\n}\n\n.specimen-btn {\n    width: 100%;\n    min-width: 0;\n    height: 100%;\n    padding: 0;\n    margin: 0;\n    display: flex;\n    flex-direction: column;\n    overflow: hidden;\n    position: relative;\n    border: 1px solid var(--specimen-border);\n    border-radius: 12px;\n    background: var(--specimen-card-bg);\n    color: var(--specimen-fg);\n    font: inherit;\n    cursor: pointer;\n     \n    touch-action: pan-y;\n    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);\n    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;\n}\n\n.specimen-btn-image-container {\n    width: 100%;\n    aspect-ratio: 16 / 10;\n    flex: 0 0 auto;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    overflow: hidden;\n    background: var(--specimen-preview-bg);\n    border-bottom: 1px solid var(--specimen-border);\n}\n\n.specimen-btn-image {\n    display: block;\n    width: 100%;\n    height: 100%;\n    padding: 0;\n    object-fit: contain;  \n}\n\n.specimen-btn-text {\n    min-width: 0;\n    min-height: 54px;\n    flex: 1 0 auto;\n    padding: 10px 12px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    color: var(--specimen-fg);\n    font-size: 14px;\n    font-weight: 600;\n    line-height: 1.35;\n    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n}\n\n@media (hover: hover) {\n    .specimen-btn:hover {\n        border-color: var(--secondary, #888);\n        transform: translateY(-3px);\n        box-shadow: 0 5px 16px rgba(0, 0, 0, 0.14);\n    }\n}\n\n.specimen-btn.active {\n    border-color: var(--specimen-accent);\n    box-shadow: inset 0 0 0 1px var(--specimen-accent), 0 3px 12px rgba(218, 105, 93, .15);\n}\n\n.specimen-btn.active .specimen-btn-text {\n    color: var(--specimen-fg);\n}\n\n.specimen-btn:focus-visible {\n    outline: 2px solid var(--specimen-accent);\n    outline-offset: 3px;\n}\n\n.scope-wrapper {\n    width: 100%;\n    height: 700px;\n    border-radius: 50%;\n    overflow: hidden;\n    position: relative;\n    background: black;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-touch-callout: none;\n    -webkit-tap-highlight-color: transparent;\n}\n\n.dzi-viewer {\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    overflow: hidden;\n}\n\n.scope-loader {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    transform: translate(-50%, -50%);\n    z-index: 10;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 15px;\n     \n    pointer-events: none;\n}\n\n.scope-loader * {\n    pointer-events: none;\n}\n\n.loader-spinner {\n    width: 40px;\n    height: 40px;\n    border: 4px solid rgba(255, 255, 255, 0.3);\n    border-top: 4px solid #fff;\n    border-radius: 50%;\n    animation: spin 1s linear infinite;\n}\n\n.loader-text {\n    color: white;\n    font-family: Arial, sans-serif;\n    font-size: 14px;\n    text-align: center;\n}\n\n \n.scope-tile-status {\n    position: absolute;\n    left: 50%;\n    bottom: 32px;\n    z-index: 30;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: 8px;\n    max-width: calc(100% - 36px);\n    padding: 7px 12px;\n    border: 1px solid rgba(255, 255, 255, .18);\n    border-radius: 999px;\n    background: rgba(23, 27, 34, .88);\n    color: #fff;\n    font: 500 12px/1.3 system-ui, sans-serif;\n    white-space: nowrap;\n    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);\n    pointer-events: none;\n    opacity: 0;\n    visibility: hidden;\n    transform: translate(-50%, 5px);\n    transition: opacity .2s ease, transform .2s ease, visibility .2s;\n}\n\n.scope-tile-status.is-visible {\n    opacity: 1;\n    visibility: visible;\n    transform: translate(-50%, 0);\n}\n\n.scope-tile-status-spinner {\n    width: 12px;\n    height: 12px;\n    flex: none;\n    border: 2px solid rgba(255, 255, 255, .3);\n    border-top-color: #fff;\n    border-radius: 50%;\n    animation: scope-tile-spin .8s linear infinite;\n}\n\n.scope-tile-status[data-state=\"complete\"] .scope-tile-status-spinner {\n    display: none;\n}\n\n@keyframes scope-tile-spin {\n    to { transform: rotate(360deg); }\n}\n\n@media (max-width: 480px) {\n    .scope-tile-status {\n        bottom: 18px;\n        padding: 5px 9px;\n        font-size: 11px;\n    }\n}\n\n@media (prefers-reduced-motion: reduce) {\n    .scope-tile-status-spinner { animation: none; }\n    .scope-tile-status { transition: none; }\n}\n\n@keyframes spin {\n    0% { transform: translate(-50%, -50%) rotate(0deg); }\n    100% { transform: translate(-50%, -50%) rotate(360deg); }\n}\n\n.scope-aberration {\n    position: absolute;\n    inset: -20px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 2;\n    mix-blend-mode: screen;\n    opacity: 0.8;\n}\n\n.scope-aberration::before {\n    content: \"\";\n    position: absolute;\n    inset: -15px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(255,0,0,0) 50%,\n        rgba(255,50,0,0.6) 60%,\n        rgba(255,0,0,0.9) 100%\n    );\n    transform: scale(1.1);\n    filter: blur(3px);\n}\n\n.scope-aberration::after {\n    content: \"\";\n    position: absolute;\n    inset: 3px;\n    border-radius: 50%;\n    background: radial-gradient(circle at center,\n        rgba(0,0,255,0) 50%,\n        rgba(0,100,255,0.6) 90%,\n        rgba(0,0,255,0.9) 90%\n    );\n    transform: scale(0.95);\n    filter: blur(2px);\n}\n\n.scope-vignette {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    background: radial-gradient(circle at center,\n        rgba(0,0,0,0) 60%,\n        rgba(0,0,0,0.6) 80%,\n        rgba(0,0,0,0.9) 90%\n    );\n    z-index: 3;\n}\n\n.scope-with-glow {\n    position: relative;\n    width: 700px;\n    height: 700px;\n    margin: 0 auto;\n}\n\n.scope-glow {\n    position: absolute;\n    inset: -40px;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: -1;\n    background: \n        radial-gradient(circle at 40% 40%,\n            rgba(100, 200, 255, 0.6) 0%,\n            rgba(80, 180, 240, 0.4) 15%,\n            rgba(60, 160, 220, 0.2) 30%,\n            transparent 60%\n        ),\n        radial-gradient(circle at 60% 60%,\n            rgba(255, 220, 100, 0.5) 0%,\n            rgba(240, 200, 80, 0.3) 15%,\n            rgba(220, 180, 60, 0.1) 30%,\n            transparent 60%\n        );\n    filter: blur(35px);\n}\n\n.scope-glare {\n    position: absolute;\n    inset: 0;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 4;\n    background: radial-gradient(circle at 30% 30%,\n        rgba(255,255,255,0.1) 0%,\n        rgba(255,255,255,0) 50%\n    );\n    mix-blend-mode: overlay;\n}\n\n@media (max-width: 768px) {\n    .scope-container {\n        width: 95vw;\n        height: auto;\n        max-width: 500px;\n        max-height: none;\n        padding-right: 0;\n        min-height: auto;\n        margin: 5px auto 35px auto;\n    }\n\n    .specimen-info {\n        margin-bottom: 14px;\n    }\n\n    .specimen-name {\n        font-size: 20px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 14px;\n        line-height: 1.45;\n        max-width: 92vw;\n    }\n    \n    .scope-with-glow {\n        width: 95vw;\n        height: 95vw;\n        max-width: 500px;\n        max-height: 500px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n\n    .collection-controls {\n        margin-top: 20px;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 700px;\n    }\n    \n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 12px;\n    }\n}\n\n@media (max-width: 480px) {\n    .scope-container {\n        width: 90vw;\n        height: auto;\n        max-width: 400px;\n        max-height: none;\n        min-height: auto;\n        padding-right: 0;\n        margin-bottom: 30px;\n    }\n\n    .specimen-name {\n        font-size: 18px;\n        line-height: 1.25;\n    }\n\n    .specimen-description {\n        font-size: 13px;\n        line-height: 1.35;\n        max-width: 90vw;\n    }\n    \n    .scope-with-glow {\n        width: 90vw;\n        height: 90vw;\n        max-width: 400px;\n        max-height: 400px;\n    }\n    \n    .scope-wrapper {\n        height: 100%;\n        max-height: none;\n    }\n    \n    .buttons-scroll-container {\n        max-height: 480px;\n        padding: 4px 4px 12px;\n    }\n\n    .collection-buttons {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n        gap: 10px;\n    }\n\n    .specimen-btn-image-container {\n        aspect-ratio: 4 / 3;\n    }\n\n    .specimen-btn-text {\n        min-height: 58px;\n        padding: 8px 6px;\n        font-size: 12px;\n    }\n\n    .collection-title {\n        font-size: 22px;\n        margin-top: 5px;\n    }\n}\n\n\n.openseadragon-container .openseadragon-controls {\n    display: none !important;\n}\n\n.buttons-scroll-container::-webkit-scrollbar {\n    width: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-track {\n    background: transparent;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb {\n    background: var(--tertiary, #aaa);\n    border-radius: 8px;\n}\n\n.buttons-scroll-container::-webkit-scrollbar-thumb:hover {\n    background: var(--secondary, #888);\n}\n\n \n.lens-effect {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 5;\n    opacity: 0;\n}\n\n.lens-focus-in {\n    animation: focusIn 0.8s ease-out forwards;\n}\n\n.lens-focus-out {\n    animation: focusOut 0.6s ease-in forwards;\n}\n\n@keyframes focusIn {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 30%,\n            rgba(255, 255, 255, 0.3) 50%,\n            rgba(255, 255, 255, 0) 70%\n        );\n        transform: scale(0.8);\n        filter: blur(15px);\n    }\n    20% {\n        opacity: 1;\n        filter: blur(10px);\n    }\n    50% {\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0.1) 0%,\n            rgba(255, 255, 255, 0.3) 40%,\n            rgba(255, 255, 255, 0.5) 60%,\n            rgba(255, 255, 255, 0) 80%\n        );\n        filter: blur(5px);\n    }\n    80% {\n        opacity: 0.8;\n        filter: blur(2px);\n    }\n    100% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(255, 255, 255, 0) 0%,\n            rgba(255, 255, 255, 0.1) 20%,\n            rgba(255, 255, 255, 0.2) 40%,\n            rgba(255, 255, 255, 0) 60%\n        );\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes focusOut {\n    0% {\n        opacity: 0;\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.3) 0%,\n            rgba(0, 0, 0, 0.2) 30%,\n            rgba(0, 0, 0, 0.1) 50%,\n            rgba(0, 0, 0, 0) 70%\n        );\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    30% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    60% {\n        background: radial-gradient(\n            circle at center,\n            rgba(0, 0, 0, 0.4) 0%,\n            rgba(0, 0, 0, 0.3) 40%,\n            rgba(0, 0, 0, 0.1) 60%,\n            rgba(0, 0, 0, 0) 80%\n        );\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-chromatic {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 6;\n    opacity: 0;\n    mix-blend-mode: overlay;\n}\n\n.chromatic-in {\n    animation: chromaticIn 0.7s ease-out forwards;\n}\n\n.chromatic-out {\n    animation: chromaticOut 0.5s ease-in forwards;\n}\n\n@keyframes chromaticIn {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 45% 45%, rgba(255, 0, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 55% 55%, rgba(0, 255, 0, 0.3) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.3) 0%, transparent 50%);\n        transform: scale(0.9);\n        filter: blur(12px);\n    }\n    30% {\n        opacity: 0.8;\n        filter: blur(6px);\n    }\n    60% {\n        opacity: 0.6;\n        filter: blur(3px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(1.1);\n        filter: blur(0px);\n    }\n}\n\n@keyframes chromaticOut {\n    0% {\n        opacity: 0;\n        background: \n            radial-gradient(circle at 55% 55%, rgba(255, 0, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 45% 45%, rgba(0, 255, 0, 0.2) 0%, transparent 50%),\n            radial-gradient(circle at 50% 50%, rgba(0, 0, 255, 0.2) 0%, transparent 50%);\n        transform: scale(1.1);\n        filter: blur(5px);\n    }\n    40% {\n        opacity: 0.7;\n        filter: blur(8px);\n    }\n    80% {\n        opacity: 0.3;\n        filter: blur(12px);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.9);\n        filter: blur(15px);\n    }\n}\n\n.lens-flare {\n    position: absolute;\n    top: 20%;\n    left: 20%;\n    width: 30%;\n    height: 30%;\n    border-radius: 50%;\n    pointer-events: none;\n    z-index: 7;\n    opacity: 0;\n    background: radial-gradient(\n        ellipse at center,\n        rgba(255, 255, 255, 0.8) 0%,\n        rgba(255, 255, 255, 0.4) 30%,\n        rgba(255, 255, 255, 0) 70%\n    );\n}\n\n.flare-in {\n    animation: flareIn 0.8s ease-out forwards;\n}\n\n.flare-out {\n    animation: flareOut 0.6s ease-in forwards;\n}\n\n@keyframes flareIn {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.7;\n        transform: scale(1.2) rotate(90deg);\n    }\n    50% {\n        opacity: 0.4;\n        transform: scale(1) rotate(180deg);\n    }\n    75% {\n        opacity: 0.2;\n        transform: scale(0.8) rotate(270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(360deg);\n    }\n}\n\n@keyframes flareOut {\n    0% {\n        opacity: 0;\n        transform: scale(0.5) rotate(0deg);\n    }\n    25% {\n        opacity: 0.6;\n        transform: scale(1.1) rotate(-90deg);\n    }\n    50% {\n        opacity: 0.3;\n        transform: scale(0.9) rotate(-180deg);\n    }\n    75% {\n        opacity: 0.1;\n        transform: scale(0.7) rotate(-270deg);\n    }\n    100% {\n        opacity: 0;\n        transform: scale(0.5) rotate(-360deg);\n    }\n}\n\n\n.scale-bar {\n    position: absolute;\n    top: 80%;  \n    left: 50%;\n    transform: translateX(-50%);\n    text-align: center;\n    z-index: 12;\n    pointer-events: none;\n}\n\n \n.scale-bar-line {\n    width: 120px;  \n    height: 4px;\n    background: white;\n    border-radius: 2px;\n    margin: 6px auto 0 auto;\n    opacity: 0.85;\n}\n\n \n.scale-bar-text {\n    font-size: 16px;\n    color: white;\n    text-shadow: 0 0 6px black;\n    font-weight: 500;\n}\n\n\n\n \n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;\n    z-index: 25;\n}\n\n.annotation-marker {\n    position: absolute;\n    width: 24px;\n    height: 24px;\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 0.8);\n    border-radius: 50%;\n    cursor: pointer;\n    pointer-events: all;\n    transform: translate(-50%, -50%);\n    transition: all 0.3s ease;\n    z-index: 26;\n    \n     \n    touch-action: none;\n    -webkit-user-drag: none;\n}\n\n.annotation-marker:hover {\n    background: transparent;\n    border: 2px solid rgba(255, 0, 0, 1);\n    transform: translate(-50%, -50%) scale(1.3);\n    box-shadow: 0 0 12px rgba(255, 0, 0, 0.8);\n     \n    pointer-events: auto;\n}\n\n.annotations-layer {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    pointer-events: none;  \n    z-index: 25;\n}\n\n\n.annotation-tooltip {\n    position: absolute;\n    background: rgba(0, 0, 0, 0.9);\n    color: white;\n    padding: 8px 12px;\n    border-radius: 6px;\n    font-size: 12px;\n    max-width: 200px;  \n    z-index: 27;\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity 0.3s ease;\n    border-left: 3px solid #ff3232;\n\n     \n    white-space: normal;   \n    word-wrap: break-word;  \n    overflow-wrap: break-word;  \n    box-sizing: border-box;  \n}\n\n\n.annotation-marker:hover + .annotation-tooltip {\n    opacity: 1;\n}\n\n \n.annotation-polygons {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    overflow: hidden;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon {\n    fill: none;\n    stroke-width: 2;\n    stroke-linejoin: round;\n    vector-effect: non-scaling-stroke;\n    pointer-events: none;\n}\n\n.annotation-polygons .annotation-polygon.is-hovered {\n    stroke-width: 3;\n}\n\n.annotation-polygon-tooltip.is-visible {\n    opacity: 1;\n}\n\n \n.scope-ruler-button { position:absolute; top:20px; left:calc(var(--scope-control-axis, 26px) - 38px); z-index:70; width:76px; height:76px; border:2px solid #73869a; border-radius:50%; padding:16px; display:grid; place-items:center; background:#151d28e6; color:#e4edf8; cursor:pointer; box-shadow:0 2px 8px #0005; }\n.scope-ruler-button svg { width:40px; height:40px; }\n.scope-ruler-button:hover, .scope-ruler-button[aria-pressed=\"true\"] { background:#284560; border-color:#8bbff4; }\n.scope-ruler-button:disabled { opacity:.45; cursor:default; }\n.scope-ruler-button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n.scope-measurement-panel { position:absolute; z-index:75; top:104px; left:calc(var(--scope-control-axis, 26px) - 60px); display:flex; justify-content:space-between; width:120px; padding:0; border:0; background:none; color:#e2e8f0; }\n.scope-measurement-panel[hidden] { display:none; }\n.scope-measurement-panel output { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }\n.scope-measurement-panel button { display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px; padding:8px; border:1px solid #526c86; border-radius:50%; color:inherit; background:#34475bf2; cursor:pointer; }\n.scope-measurement-panel button svg { width:26px; height:26px; pointer-events:none; }\n.scope-measurement-panel button:hover { background:#284560; border-color:#8bbff4; }\n.scope-measurement-panel button:focus-visible { outline:2px solid #81b8ff; outline-offset:3px; }\n@media (max-width:700px) { .scope-measurement-panel { left:0; width:100px; } }\n.scope-measurement-overlay { position:absolute; inset:0; z-index:36; width:100%; height:100%; overflow:hidden; pointer-events:none; }\n.scope-measurement-overlay[hidden] { display:none; }\n.scope-measurement-overlay line { stroke:#fff; stroke-width:2; vector-effect:non-scaling-stroke; filter:drop-shadow(0 1px 2px #000); }\n.scope-measurement-overlay circle { fill:#163f60; stroke:#fff; stroke-width:2; cursor:move; pointer-events:all; }\n.scope-measurement-overlay circle:focus { fill:#4589c1; outline:none; stroke:#92d4ff; }\n.scope-measurement-overlay text { fill:white; stroke:#000; stroke-width:3px; paint-order:stroke; stroke-linejoin:round; font:13px \"Segoe UI\",Arial,sans-serif; }\n.scope-wrapper.is-measuring .openseadragon-canvas { cursor:crosshair; }\n.scope-wrapper.is-measuring .annotations-layer, .scope-wrapper.is-measuring .annotation-marker { pointer-events:none; }\n \n.microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n    top: 20px;\n    right: calc(var(--scope-control-axis, 26px) - 38px);\n    width: 76px;\n    height: 76px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n    width: 76px;\n    height: 76px;\n    border-width: 2px;\n}\n.microscope-collection .scope-container .fossa-specimen-info-button \u003e svg {\n    width: 48px;\n    height: 48px;\n}\n.microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n    top: 84px;\n}\n\n \n.annotation-toggle-btn {\n    background: var(--entry, #f8f9fa);\n    border: 1px solid var(--border, #dee2e6);\n    padding: 8px 16px;\n    border-radius: 6px;\n    cursor: pointer;\n    font-size: 14px;\n    transition: all 0.3s ease;\n    margin: 0 auto 10px auto;\n    display: block;\n    color: var(--primary, #212529);\n    font-family: inherit;\n}\n\n.annotation-toggle-btn:hover {\n    background: var(--code-bg, #e9ecef);\n    border-color: var(--secondary, #adb5bd);\n    transform: translateY(-1px);\n}\n\n.annotation-toggle-btn.active {\n    background: #bd5147;\n    color: white;\n    border-color: #bd5147;\n    box-shadow: 0 2px 6px rgba(189, 81, 71, 0.22);\n}\n\n.annotation-toggle-btn:focus {\n    outline: 2px solid #bd5147;\n    outline-offset: 2px;\n}\n \n@media (max-width: 480px) {\n    .annotations-layer,\n    .annotation-marker,\n    .annotation-tooltip {\n        display: none !important;\n    }\n    \n    .annotation-toggle-btn {\n        display: none !important;\n    }\n}\n\n\n \n.microscope-collection--compact {\n    display: inline-block;\n    vertical-align: top;\n    box-sizing: border-box;\n    width: var(--fossa-compact-width, 48%);\n    max-width: 100%;\n    margin: 0 .45% 20px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-container {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    min-height: 0;\n    height: auto;\n    max-width: none;\n    margin: 0 auto 10px;\n    padding: 0;\n}\n\n.microscope-collection--compact .scope-with-glow {\n    box-sizing: border-box;\n    position: relative;\n    width: 100%;\n    height: auto;\n    aspect-ratio: 1 / 1;\n    max-width: none;\n    max-height: none;\n    margin: 0;\n}\n\n.microscope-collection--compact .scope-wrapper {\n    position: absolute;\n    inset: 0;\n    width: 100%;\n    height: 100%;\n    min-height: 0;\n    max-height: none;\n}\n\n.microscope-collection--compact .scale-bar-line {\n    height: 2px;\n    border-radius: 1px;\n    margin-top: 3px;\n}\n\n.microscope-collection--compact .scale-bar-text {\n    font-size: clamp(10px, 1.15vw, 12px);\n    line-height: 1.2;\n}\n\n.microscope-collection--compact .scope-glow {\n    inset: -16px;\n    filter: blur(16px);\n    opacity: .75;\n}\n\n.microscope-collection--compact .scope-loader .loader-spinner {\n    width: 28px;\n    height: 28px;\n    border-width: 3px;\n}\n\n.microscope-collection--compact .scope-loader .loader-text {\n    font-size: 11px;\n}\n\n.microscope-collection--compact .annotation-toggle-btn {\n    padding: 5px 10px;\n    font-size: 12px;\n}\n\n.microscope-collection--compact .collection-controls {\n    margin: 0;\n}\n\n@media (max-width: 700px) {\n    .microscope-collection { --scope-control-axis: 33.5px; }  \n    .microscope-collection--modern { --scope-control-axis: 35.5px; }  \n    .microscope-collection--compact {\n        display: block;\n        width: min(100%, 480px);\n        max-width: 100%;\n        margin: 0 auto 22px;\n    }\n}\n\n\n \n@media (max-width: 700px) {\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button {\n        top: 10px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n        padding: 7px;\n        border-width: 1px;\n        box-sizing: border-box;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-ruler-button svg {\n        width: 20px;\n        height: 20px;\n    }\n\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control {\n        top: 10px;\n        right: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 38px;\n        height: 38px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button {\n        width: 38px;\n        height: 38px;\n        padding: 0;\n        border-width: 1px;\n    }\n    .microscope-collection .scope-container .scope-with-glow \u003e .fossa-specimen-info-control \u003e .fossa-specimen-info-button \u003e svg {\n        width: 24px;\n        height: 24px;\n    }\n\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel {\n        top: 54px;\n        left: calc(var(--scope-control-axis, 33.5px) - 38px);\n        width: 76px;\n        gap: 4px;\n        justify-content: flex-start;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button {\n        flex: 0 0 34px;\n        width: 34px;\n        height: 34px;\n        padding: 5px;\n    }\n    .microscope-collection .scope-with-glow \u003e .scope-measurement-panel button svg {\n        width: 20px;\n        height: 20px;\n    }\n    .microscope-collection .scope-container .scope-with-glow .fossa-specimen-info-panel {\n        top: 50px;\n    }\n}\n\n\u003c/style\u003e\n\n\n\u003clink rel=\"stylesheet\" href=\"/css/fossa-microscope-modern.css\"\u003e\n\u003cscript defer src=\"/js/fossa-microscope-modern.js\"\u003e\u003c/script\u003e\n\n\n\u003cdiv class=\"microscope-collection microscope-collection--modern\"\n     id=\"collection-0\"\u003e\n    \u003cdiv class=\"scope-container\"\u003e\n        \n        \u003cdiv class=\"specimen-info specimen-info--single\"\u003e\n          \u003cdiv class=\"specimen-name\" id=\"specimen-name-0\" style=\"display:none\"\u003e\u003c/div\u003e\n          \u003cdiv class=\"specimen-description\" id=\"specimen-desc-0\" style=\"display:none\"\u003e\u003c/div\u003e\n        \u003c/div\u003e\n        \n\n        \u003cdiv class=\"scope-with-glow\"\u003e\n\n    \u003cdiv class=\"scope-adjust\"  role=\"group\"\n         aria-label=\"Image adjustments\"\u003e\n      \u003cdiv class=\"scope-knob scope-knob--brightness\" data-control=\"brightness\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"70\" aria-valuemax=\"130\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Brightness\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eBrightness\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"scope-knob scope-knob--contrast\" data-control=\"contrast\" tabindex=\"0\"\n           role=\"slider\" aria-valuemin=\"40\" aria-valuemax=\"200\" aria-valuenow=\"100\"\n           aria-valuetext=\"100%\" aria-label=\"Contrast\"\n           title=\"Mouse wheel or turn the dial; tap the center to reset\"\u003e\n        \u003csvg class=\"scope-knob__dial\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"\u003e\n          \u003cpath class=\"scope-knob__arc\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003cpath class=\"scope-knob__arc-mark\" d=\"M12 68 A48 48 0 0 1 108 68\" /\u003e\n          \u003ccircle class=\"scope-knob__inner\" cx=\"60\" cy=\"68\" r=\"30\" /\u003e\n          \u003cg class=\"scope-knob__needle\"\u003e\n            \u003cpath d=\"M60 68 L60 42\" /\u003e\n          \u003c/g\u003e\n          \u003ccircle class=\"scope-knob__center\" cx=\"60\" cy=\"68\" r=\"3\" /\u003e\n        \u003c/svg\u003e\n        \u003cspan class=\"scope-knob__info\"\u003e\n          \u003cspan\u003eContrast\u003c/span\u003e\n          \u003coutput\u003e100%\u003c/output\u003e\n        \u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"fossa-specimen-info-control\"\u003e\n      \u003cbutton type=\"button\" class=\"fossa-specimen-info-button\"\n              aria-label=\"Specimen description\"\n              title=\"Show specimen description\"\n              aria-expanded=\"false\" aria-controls=\"fossa-specimen-info-panel-0\"\u003e\n        \u003csvg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\"\n             stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\n          \u003ccircle cx=\"12\" cy=\"12\" r=\"9.25\"/\u003e\n          \u003ccircle cx=\"12\" cy=\"7.7\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\"/\u003e\n          \u003cpath d=\"M12 11v5.5\"/\u003e\n        \u003c/svg\u003e\n      \u003c/button\u003e\n      \u003cdiv class=\"fossa-specimen-info-panel\" id=\"fossa-specimen-info-panel-0\"\n           role=\"region\" aria-label=\"Specimen description\"\u003e\n        \u003cdiv class=\"fossa-specimen-info-panel__text\"\u003e\u003c/div\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n\n            \u003cdiv class=\"scope-glow\"\u003e\u003c/div\u003e\n            \u003cdiv class=\"scope-wrapper\" id=\"scope-0\"\u003e\n                \u003cdiv class=\"scale-bar\" id=\"scale-bar-0\"\u003e\n                    \u003cdiv class=\"scale-bar-line\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"scale-bar-text\" id=\"scale-bar-text-0\"\u003e—\u003c/div\u003e\n                \u003c/div\u003e\n\n\t\t\t\u003cdiv class=\"annotations-layer\" id=\"annotations-0\"\u003e\u003c/div\u003e\n\n\n                \u003cdiv id=\"dzi-viewer-0\" class=\"dzi-viewer\"\u003e\u003c/div\u003e\n                \n                \n                \u003cdiv class=\"lens-effect\" id=\"lens-effect-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-chromatic\" id=\"lens-chromatic-0\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"lens-flare\" id=\"lens-flare-0\"\u003e\u003c/div\u003e\n                \n                               \n                \n                \u003cdiv class=\"scope-loader\" id=\"loader-0\"\u003e\n                    \u003cdiv class=\"loader-spinner\"\u003e\u003c/div\u003e\n                    \u003cdiv class=\"loader-text\" id=\"loader-text-0\"\u003eLoading image…\u003c/div\u003e\n                \u003c/div\u003e\n                \u003cdiv class=\"scope-aberration\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-glare\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-vignette\"\u003e\u003c/div\u003e\n                \u003cdiv class=\"scope-tile-status\" id=\"tile-status-0\"\n                     role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"\n                     data-text-loading=\"Loading details…\"\n                     data-text-complete=\"Loaded\"\u003e\n                    \u003cspan class=\"scope-tile-status-spinner\" aria-hidden=\"true\"\u003e\u003c/span\u003e\n                    \u003cspan class=\"scope-tile-status-text\"\u003e\u003c/span\u003e\n                \u003c/div\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"scope-photo-actions\"\u003e\n          \u003cbutton type=\"button\" class=\"fossa-shortcode-fullscreen\"\n            aria-pressed=\"false\"\n            data-enter=\"Fullscreen\"\n            data-exit=\"Exit fullscreen\"\u003e\n            \u003cspan aria-hidden=\"true\"\u003e⛶\u003c/span\u003e\u003cspan class=\"fossa-shortcode-fullscreen-text\"\u003eFullscreen\u003c/span\u003e\n          \u003c/button\u003e\n    \u003cbutton type=\"button\" class=\"scope-photo-button\"\n      title=\"Save current field of view with scale bar as PNG\"\n      aria-label=\"Capture specimen image\"\u003e\n      \u003csvg viewBox=\"0 0 24 24\" width=\"17\" height=\"17\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\n        \u003cpath d=\"M4 7h4l2-3h4l2 3h4a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Z\"/\u003e\n        \u003ccircle cx=\"12\" cy=\"13\" r=\"3.5\"/\u003e\n      \u003c/svg\u003e\n      \u003cspan\u003eCapture\u003c/span\u003e\n    \u003c/button\u003e\n        \u003c/div\u003e\n        \n    \u003c/div\u003e\n\n\u003cdiv class=\"collection-controls\"\u003e\n\n    \u003cbutton id=\"toggle-annotations-0\" \n            class=\"annotation-toggle-btn\"\n            data-text-off=\"Annotations: Off\"\n            data-text-on=\"Annotations: On\"\u003e\n        Annotations: Off\n    \u003c/button\u003e\n\n    \n    \u003cdiv class=\"collection-buttons\" id=\"specimen-buttons-0\" style=\"display:none\"\u003e\u003c/div\u003e\n    \n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\n\n\n\n\n\n\n\u003cscript\u003e\n(function () {\n    if (typeof window.OpenSeadragon !== 'undefined') {\n        return;\n    }\n\n    if (document.querySelector('script[data-fossa-openseadragon]')) {\n        return;\n    }\n\n    const script = document.createElement('script');\n    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.1/openseadragon.min.js';\n    script.async = true;\n    script.dataset.fossaOpenseadragon = 'true';\n\n    script.addEventListener('load', function () {\n        console.log('YYYYY');\n    });\n\n    script.addEventListener('error', function () {\n        console.error('Не удалось загрузить OpenSeadragon:', script.src);\n    });\n\n    document.head.appendChild(script);\n})();\n\u003c/script\u003e\n\n\u003cscript\u003e\n(function() {\n    const id = \"0\";\n    const shortcodeSlide = \"Kidney_1-sc.dzi\";\n    const singleMode = true;\n    const compactMode = false;\n    const loader = document.getElementById(\"loader-\" + id);\n    const loaderText = document.getElementById(\"loader-text-\" + id);\n    const tileStatus = document.getElementById(\"tile-status-\" + id);\n    const tileStatusText = tileStatus ? tileStatus.querySelector('.scope-tile-status-text') : null;\n    const specimenName = document.getElementById(\"specimen-name-\" + id);\n    const specimenDesc = document.getElementById(\"specimen-desc-\" + id);\n    const specimenButtons = document.getElementById(\"specimen-buttons-\" + id);\n    const viewerContainer = document.getElementById(\"dzi-viewer-\" + id);\n    const lensEffect = document.getElementById(\"lens-effect-\" + id);\n    const lensChromatic = document.getElementById(\"lens-chromatic-\" + id);\n    const lensFlare = document.getElementById(\"lens-flare-\" + id);\n    \n    let currentAnnotations = [];\n    let showAnnotations = false;\n    let annotationDisposers = [];\n    \n    const specimens = [\n        \n        {\n            id:  0 ,\n            name: \"Yellowtail kidney — tubular destruction\",\n            description: \"Panoramic compression preparation of yellowtail kidney. Areas with relatively preserved lighter tubular lumina can be compared with zones where the lumina are filled with dark material, corresponding to marked pathological change.\",\n            buttonImage: \"/dzi/images/Kidney_1-sc.webp\",\n            dzi: \"Kidney_1-sc.dzi\",\n            unit: \"µm\",\n            microns_per_pixel:  15.2 ,\n            image_microns_per_pixel:  0 ,\n            calibration_unit: \"\",\n            roi_file: \"/annotations/Kidney_1-sc.json\",\n            previewAlt: \"Yellowtail kidney microscopy showing clear and dark-material-filled renal tubular lumina\",\n            pageUrl: \"/en/microscope-collection/kidney_1-sc/\"\n        }\n        \n    ];\n\n    let viewer = null;\n    \n    let compactLastWidth = 0;\n    let currentSpecimen = null;\n    let isTransitioning = false;\n    let currentZoomLevel = 1;\n    let lastZoomLevel = 1;\n    let zoomLevelTimeout = null;\n\n    \n    \n    let firstTileDrawn = false;\n    let tilesPending = false;\n    let tileShowTimer = null;\n    let tileHideTimer = null;\n    let firstTileFallbackTimer = null;\n\n    function resetTileStatus() {\n        clearTimeout(tileShowTimer);\n        clearTimeout(tileHideTimer);\n        clearTimeout(firstTileFallbackTimer);\n        tileShowTimer = null;\n        tileHideTimer = null;\n        firstTileFallbackTimer = null;\n        tilesPending = false;\n        firstTileDrawn = false;\n        if (tileStatus) {\n            tileStatus.classList.remove('is-visible');\n            tileStatus.dataset.state = '';\n        }\n    }\n\n    function updateTileStatus(fullyLoaded) {\n        if (!tileStatus || !tileStatusText || !firstTileDrawn) return;\n\n        if (!fullyLoaded) {\n            tilesPending = true;\n            clearTimeout(tileHideTimer);\n            tileHideTimer = null;\n            if (tileStatus.dataset.state === 'loading') return;\n\n            \n            tileStatus.classList.remove('is-visible');\n            clearTimeout(tileShowTimer);\n            tileShowTimer = setTimeout(() =\u003e {\n                if (!tilesPending || !firstTileDrawn) return;\n                tileStatus.dataset.state = 'loading';\n                tileStatusText.textContent = tileStatus.dataset.textLoading;\n                tileStatus.classList.add('is-visible');\n            }, 160);\n            return;\n        }\n\n        if (!tilesPending) return;\n        tilesPending = false;\n        clearTimeout(tileShowTimer);\n        tileShowTimer = null;\n        if (tileStatus.dataset.state !== 'loading') return;\n\n        tileStatus.dataset.state = 'complete';\n        tileStatusText.textContent = tileStatus.dataset.textComplete;\n        tileStatus.classList.add('is-visible');\n        clearTimeout(tileHideTimer);\n        tileHideTimer = setTimeout(() =\u003e {\n            tileStatus.classList.remove('is-visible');\n        }, 1100);\n    }\n\n   \n\nfunction updateAnnotationButtonText() {\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    if (button) {\n        const textOff = button.dataset.textOff || 'Annotations: Off';\n        const textOn = button.dataset.textOn || 'Annotations: On';\n        \n        button.textContent = showAnnotations ? textOn : textOff;\n    }\n}\n\n\n\n\nasync function loadAnnotations(roiFilePath) {\n  \n    \n    if (!roiFilePath || roiFilePath === '\"\"' || roiFilePath === '') {\n        console.log('Путь к аннотациям пустой или не указан');\n        currentAnnotations = [];\n        return;\n    }\n    \n    try {\n\n        const cleanPath = roiFilePath.replace(/^\"|\"$/g, ''); \n        const fullPath = cleanPath.startsWith('http') ? cleanPath : window.location.origin + cleanPath;\n  \n        \n \n        const response = await fetch(fullPath);\n       \n        \n        if (!response.ok) {\n            throw new Error(`HTTP error! status: ${response.status}`);\n        }\n        \n\t\tconst data = await response.json();\n        \n        if (Array.isArray(data)) {\n            \n            currentAnnotations = data;\n        } else if (typeof data === 'object' \u0026\u0026 data !== null) {\n            \n            currentAnnotations = [data];\n        } else {\n            currentAnnotations = [];\n        }\n        \n\n        currentAnnotations.forEach((group, index) =\u003e {\n            console.log(`   Группа ${index}: ${group.id}, точек: ${group.points?.length || 0}`);\n        });\n        \n        if (showAnnotations \u0026\u0026 currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            console.log('Аннотации не показываем (showAnnotations:', showAnnotations, 'групп:', currentAnnotations.length, ')');\n        }\n        \n    } catch (error) {\n        currentAnnotations = [];\n    }\n}\n\n\nfunction originalMicronsPerPixel(specimen, imageWidth) {\n  const direct = Number(specimen?.image_microns_per_pixel);\n  if (Number.isFinite(direct) \u0026\u0026 direct \u003e 0) return direct;\n  const legacy = Number(specimen?.microns_per_pixel);\n  return Number.isFinite(legacy) \u0026\u0026 legacy \u003e 0 \u0026\u0026 Number.isFinite(imageWidth) \u0026\u0026 imageWidth \u003e 0\n    ? legacy * 700 * (149 / 154) / imageWidth : null;\n}\n\nfunction measureSegment(start, end, specimen, imageWidth) {\n  const pixels = Math.hypot(end.x - start.x, end.y - start.y);\n  const scale = originalMicronsPerPixel(specimen, imageWidth);\n  return { pixels, microns: scale === null ? null : pixels * scale };\n}\n\nfunction formatMeasurement(measurement, preferredUnit = '', missingScaleText = 'масштаб не задан') {\n  if (measurement.microns === null) return `${Number(measurement.pixels.toFixed(2))} px · ${missingScaleText}`;\n  const mm = preferredUnit === 'mm' || (!preferredUnit \u0026\u0026 measurement.microns \u003e= 1000);\n  return `${Number((measurement.microns / (mm ? 1000 : 1)).toPrecision(5))} ${mm ? 'mm' : 'µm'}`;\n}\n\n\n\n\nfunction bindImagePointDrag({ element, viewer, blocked, move, click }) {\n  let drag = null;\n  let suppressClick = false;\n  const press = event =\u003e {\n    if (blocked() || event.button !== 0) return;\n    event.preventDefault();\n    event.stopPropagation();\n    const rect = element.getBoundingClientRect();\n    suppressClick = false;\n    drag = {\n      id: event.pointerId, x: event.clientX, y: event.clientY,\n      offsetX: event.clientX - rect.left - rect.width / 2,\n      offsetY: event.clientY - rect.top - rect.height / 2,\n      navigation: viewer.isMouseNavEnabled(), moved: false,\n    };\n    viewer.setMouseNavEnabled(false);\n    element.setPointerCapture(event.pointerId);\n  };\n  const update = event =\u003e {\n    if (!drag || event.pointerId !== drag.id || blocked()) return;\n    event.preventDefault();\n    event.stopPropagation();\n    if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) \u003e 2) drag.moved = true;\n    if (!drag.moved) return;\n    const rect = viewer.element.getBoundingClientRect();\n    move({ x: event.clientX - rect.left - drag.offsetX, y: event.clientY - rect.top - drag.offsetY });\n  };\n  const release = event =\u003e {\n    if (!drag || (event \u0026\u0026 event.pointerId !== drag.id)) return;\n    event?.stopPropagation();\n    const previous = drag;\n    drag = null;\n    suppressClick = previous.moved;\n    if (element.hasPointerCapture(previous.id)) element.releasePointerCapture(previous.id);\n    viewer.setMouseNavEnabled(previous.navigation \u0026\u0026 !blocked());\n  };\n  const activate = event =\u003e {\n    event.preventDefault();\n    event.stopPropagation();\n    if (!blocked() \u0026\u0026 !suppressClick) click();\n    suppressClick = false;\n  };\n  element.addEventListener('pointerdown', press);\n  element.addEventListener('pointermove', update);\n  element.addEventListener('click', activate);\n  for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.addEventListener(name, release);\n  return { destroy() {\n    release();\n    element.removeEventListener('pointerdown', press);\n    element.removeEventListener('pointermove', update);\n    element.removeEventListener('click', activate);\n    for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) element.removeEventListener(name, release);\n  } };\n}\n\nfunction installMeasurementTool({ viewer, getSpecimen }) {\n  const russian = false;\n  const text = russian ? {\n    title: 'Измерить расстояние', name: 'Измерительная линейка',\n    prompt: 'Протяни линию по изображению.',\n    newLine: 'Новая линия', close: 'Убрать',\n    start: 'Начало измерения', end: 'Конец измерения', missingScale: 'масштаб не задан'\n  } : {\n    title: 'Measure distance', name: 'Measurement ruler',\n    prompt: 'Drag a line across the image.',\n    newLine: 'New line', close: 'Hide',\n    start: 'Start of measurement', end: 'End of measurement', missingScale: 'scale not set'\n  };\n  const container = viewer.element;\n  const lens = container.closest('.scope-with-glow');\n  const wrapper = container.closest('.scope-wrapper');\n  const button = document.createElement('button');\n  button.type = 'button';\n  button.className = 'scope-ruler-button';\n  button.title = text.title;\n  button.setAttribute('aria-label', text.name);\n  button.setAttribute('aria-pressed', 'false');\n  button.innerHTML = '\u003csvg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m3 16 13-13 5 5L8 21z\"/\u003e\u003cpath d=\"m7 12 2 2m2-6 2 2m2-6 2 2\"/\u003e\u003c/svg\u003e';\n  const panel = document.createElement('div');\n  panel.className = 'scope-measurement-panel';\n  panel.setAttribute('role', 'group');\n  panel.setAttribute('aria-label', text.name);\n  panel.hidden = true;\n  panel.innerHTML = '\u003coutput aria-live=\"polite\"\u003e\u003c/output\u003e\u003cbutton type=\"button\" data-new\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"M20 11a8 8 0 1 0-2.3 6.7L21 14\"/\u003e\u003cpath d=\"M21 20v-6h-6\"/\u003e\u003c/svg\u003e\u003c/button\u003e\u003cbutton type=\"button\" data-close\u003e\u003csvg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" aria-hidden=\"true\"\u003e\u003cpath d=\"m5 5 14 14M19 5 5 19\"/\u003e\u003c/svg\u003e\u003c/button\u003e';\n  panel.querySelector('output').textContent = text.prompt;\n  for (const [selector, label] of [['[data-new]', text.newLine], ['[data-close]', text.close]]) {\n    const action = panel.querySelector(selector);\n    action.title = label;\n    action.setAttribute('aria-label', label);\n  }\n  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n  svg.classList.add('scope-measurement-overlay');\n  svg.innerHTML = '\u003cline/\u003e\u003ccircle r=\"7\" data-endpoint=\"start\" tabindex=\"0\" role=\"button\" aria-label=\"Начало измерения\"/\u003e\u003ccircle r=\"7\" data-endpoint=\"end\" tabindex=\"0\" role=\"button\" aria-label=\"Конец измерения\"/\u003e\u003ctext/\u003e';\n  svg.querySelector('[data-endpoint=\"start\"]').setAttribute('aria-label', text.start);\n  svg.querySelector('[data-endpoint=\"end\"]').setAttribute('aria-label', text.end);\n  svg.setAttribute('hidden', '');\n  wrapper.append(svg);\n  lens.append(button, panel);\n  const output = panel.querySelector('output');\n  const line = svg.querySelector('line');\n  const label = svg.querySelector('text');\n  const handles = [...svg.querySelectorAll('circle')];\n  let active = false;\n  let drawing = false;\n  let dragging = false;\n  let segment = null;\n  let navigation = [];\n  let labelText = '';\n\n  function setDrawing(value) {\n    if (value === drawing) return;\n    drawing = value;\n    const settings = [viewer.gestureSettingsMouse, viewer.gestureSettingsTouch, viewer.gestureSettingsPen];\n    if (drawing) { navigation = settings.map(s =\u003e s.dragToPan); settings.forEach(s =\u003e { s.dragToPan = false; }); }\n    else settings.forEach((s, i) =\u003e { s.dragToPan = navigation[i]; });\n    wrapper.classList.toggle('is-measuring', drawing);\n  }\n  function pointAt(pixel, clamp = false) {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return null;\n    const size = item.getContentSize();\n    const p = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    if (!clamp \u0026\u0026 (p.x \u003c 0 || p.y \u003c 0 || p.x \u003e size.x || p.y \u003e size.y)) return null;\n    return { x: Math.max(0, Math.min(size.x, p.x)), y: Math.max(0, Math.min(size.y, p.y)) };\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    svg.toggleAttribute('hidden', !active || !segment || !item);\n    if (svg.hasAttribute('hidden')) return;\n    const project = point =\u003e viewer.viewport.pixelFromPoint(item.imageToViewportCoordinates(point.x, point.y, true), true);\n    const start = project(segment.start), end = project(segment.end);\n    line.setAttribute('x1', start.x); line.setAttribute('y1', start.y);\n    line.setAttribute('x2', end.x); line.setAttribute('y2', end.y);\n    handles.forEach((handle, i) =\u003e {\n      const point = i ? end : start;\n      handle.setAttribute('cx', point.x); handle.setAttribute('cy', point.y);\n      handle.style.pointerEvents = drawing ? 'none' : 'all';\n    });\n    const specimen = getSpecimen();\n    labelText = formatMeasurement(measureSegment(segment.start, segment.end, specimen, item.getContentSize().x), specimen?.calibration_unit, text.missingScale);\n    output.textContent = labelText;\n    label.textContent = labelText;\n    label.setAttribute('x', (start.x + end.x) / 2);\n    label.setAttribute('y', (start.y + end.y) / 2 - 13);\n    label.setAttribute('text-anchor', 'middle');\n  }\n  function reset() {\n    segment = null;\n    svg.setAttribute('hidden', '');\n    output.textContent = text.prompt;\n    setDrawing(active);\n  }\n  function enable(value) {\n    active = value;\n    button.setAttribute('aria-pressed', String(value));\n    panel.hidden = !value;\n    if (value) reset();\n    else { setDrawing(false); segment = null; svg.setAttribute('hidden', ''); }\n  }\n  button.addEventListener('click', () =\u003e enable(!active));\n  panel.querySelector('[data-new]').addEventListener('click', reset);\n  panel.querySelector('[data-close]').addEventListener('click', () =\u003e enable(false));\n  viewer.addHandler('canvas-press', event =\u003e {\n    if (!drawing || event.originalEvent?.button \u003e 0) return;\n    const point = pointAt(event.position);\n    if (!point) return;\n    event.preventDefaultAction = true;\n    segment = { start: point, end: point };\n    dragging = true;\n    update();\n  });\n  viewer.addHandler('canvas-drag', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    segment.end = pointAt(event.position, true);\n    update();\n  });\n  viewer.addHandler('canvas-release', event =\u003e {\n    if (!drawing || !dragging) return;\n    event.preventDefaultAction = true;\n    dragging = false;\n    segment.end = pointAt(event.position, true);\n    setDrawing(false);\n    update();\n  });\n  for (const handle of handles) {\n    const key = handle.dataset.endpoint;\n    bindImagePointDrag({ element: handle, viewer, blocked: () =\u003e !active || drawing || !segment,\n      move: position =\u003e { segment[key] = pointAt(new OpenSeadragon.Point(position.x, position.y), true); update(); },\n      click: () =\u003e handle.focus(),\n    });\n    handle.addEventListener('keydown', event =\u003e {\n      if (!active || drawing || !segment) return;\n      const delta = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n      if (!delta) return;\n      event.preventDefault(); event.stopPropagation();\n      const size = viewer.world.getItemAt(0).getContentSize(), step = event.shiftKey ? 10 : 1;\n      segment[key] = { x: Math.max(0, Math.min(size.x, segment[key].x + delta[0] * step)), y: Math.max(0, Math.min(size.y, segment[key].y + delta[1] * step)) };\n      update();\n    });\n  }\n  document.addEventListener('keydown', event =\u003e {\n    if (event.key === 'Escape' \u0026\u0026 active \u0026\u0026 !event.target.closest('input,textarea,select')) enable(false);\n  });\n  viewer.addHandler('open', () =\u003e { button.disabled = false; enable(false); });\n  viewer.addHandler('close', () =\u003e { button.disabled = true; enable(false); });\n  button.disabled = !viewer.world.getItemAt(0);\n  for (const name of ['animation', 'zoom', 'pan', 'resize']) viewer.addHandler(name, update);\n}\n\nconst EPS = 1e-12;\nconst cross = (a, b, c) =\u003e (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);\nconst onSegment = (point, a, b) =\u003e Math.abs(cross(a, b, point)) \u003c= EPS \u0026\u0026\n  point.x \u003e= Math.min(a.x,b.x)-EPS \u0026\u0026 point.x \u003c= Math.max(a.x,b.x)+EPS \u0026\u0026\n  point.y \u003e= Math.min(a.y,b.y)-EPS \u0026\u0026 point.y \u003c= Math.max(a.y,b.y)+EPS;\n\nfunction polygonArea(vertices) {\n  return Math.abs(vertices.reduce((sum, point, i) =\u003e {\n    const next = vertices[(i+1)%vertices.length];\n    return sum + point.x*next.y - next.x*point.y;\n  }, 0))/2;\n}\n\nfunction validPolygon(vertices) {\n  if (!Array.isArray(vertices) || vertices.length \u003c 3 || vertices.length \u003e 1000 ||\n      vertices.some(p =\u003e !p || !Number.isFinite(p.x) || !Number.isFinite(p.y) || p.x \u003c 0 || p.x \u003e 1 || p.y \u003c 0 || p.y \u003e 1) ||\n      polygonArea(vertices) \u003c= EPS) return false;\n  for (let i=0; i\u003cvertices.length; i++) {\n    const a = vertices[i], b = vertices[(i+1)%vertices.length];\n    if (Math.hypot(a.x-b.x, a.y-b.y) \u003c= EPS) return false;\n    for (let j=i+1; j\u003cvertices.length; j++) {\n      if (j === i+1 || (i === 0 \u0026\u0026 j === vertices.length-1)) continue;\n      const c = vertices[j], d = vertices[(j+1)%vertices.length];\n      const abC = cross(a,b,c), abD = cross(a,b,d), cdA = cross(c,d,a), cdB = cross(c,d,b);\n      if ((abC*abD \u003c -EPS*EPS \u0026\u0026 cdA*cdB \u003c -EPS*EPS) ||\n          onSegment(c,a,b) || onSegment(d,a,b) || onSegment(a,c,d) || onSegment(b,c,d)) return false;\n    }\n  }\n  return true;\n}\n\n\nfunction pointInPolygon(point, vertices) {\n  let inside = false;\n  for (let i=0, j=vertices.length-1; i\u003cvertices.length; j=i++) {\n    const a = vertices[j], b = vertices[i];\n    if (onSegment(point,a,b)) return true;\n    if ((a.y \u003e point.y) !== (b.y \u003e point.y) \u0026\u0026 point.x \u003c (b.x-a.x)*(point.y-a.y)/(b.y-a.y)+a.x) inside = !inside;\n  }\n  return inside;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n\n\n\nfunction renderPolygonAnnotations({ viewer, container, layer, groups }) {\n  const svg = document.createElementNS(NS, 'svg');\n  svg.classList.add('annotation-polygons');\n  svg.setAttribute('aria-hidden', 'true');\n  const regions = [];\n  for (const group of groups) {\n    for (const vertices of Array.isArray(group.polygons) ? group.polygons : []) {\n      if (!validPolygon(vertices)) continue;\n      const polygon = document.createElementNS(NS, 'polygon');\n      polygon.classList.add('annotation-polygon');\n      polygon.dataset.groupId = group.id;\n      polygon.style.stroke = group.color || '#ff4444';\n      svg.append(polygon);\n      const tooltip = document.createElement('div');\n      tooltip.className = 'annotation-tooltip annotation-polygon-tooltip';\n      tooltip.style.borderLeftColor = group.color || '#ff4444';\n      const lang = document.documentElement.lang || 'ru';\n      const heading = document.createElement('strong');\n      heading.textContent = group.labels?.[lang] || group.labels?.ru || group.label || 'Область';\n      const description = group.description?.[lang] || group.description?.ru ||\n        (typeof group.description === 'string' ? group.description : '');\n      tooltip.append(heading, document.createElement('br'), document.createTextNode(description));\n      regions.push({ vertices, polygon, tooltip });\n    }\n  }\n  if (!regions.length) return () =\u003e {};\n  layer.append(svg, ...regions.map(region =\u003e region.tooltip));\n  let pointer = null;\n  function hide() {\n    regions.forEach(region =\u003e {\n      region.tooltip.classList.remove('is-visible');\n      region.polygon.classList.remove('is-hovered');\n    });\n  }\n  function hover() {\n    hide();\n    const item = viewer.world.getItemAt(0);\n    if (!pointer || !item) return;\n    const rect = container.getBoundingClientRect();\n    const pixel = new OpenSeadragon.Point(pointer.x-rect.left, pointer.y-rect.top);\n    const image = item.viewportToImageCoordinates(viewer.viewport.pointFromPixel(pixel, true));\n    const size = item.getContentSize();\n    const point = { x: image.x/size.x, y: image.y/size.y };\n    const region = regions.findLast(candidate =\u003e pointInPolygon(point, candidate.vertices));\n    if (!region) return;\n    region.polygon.classList.add('is-hovered');\n    region.tooltip.classList.add('is-visible');\n    region.tooltip.style.left = Math.max(6, Math.min(pixel.x+14, rect.width-region.tooltip.offsetWidth-6))+'px';\n    region.tooltip.style.top = Math.max(6, Math.min(pixel.y+14, rect.height-region.tooltip.offsetHeight-6))+'px';\n  }\n  function update() {\n    const item = viewer.world.getItemAt(0);\n    if (!item) return;\n    const size = item.getContentSize();\n    for (const region of regions) {\n      region.polygon.setAttribute('points', region.vertices.map(point =\u003e {\n        const screen = viewer.viewport.viewportToViewerElementCoordinates(item.imageToViewportCoordinates(point.x*size.x, point.y*size.y));\n        return `${screen.x},${screen.y}`;\n      }).join(' '));\n    }\n    hover();\n  }\n  const move = event =\u003e { pointer = { x: event.clientX, y: event.clientY }; hover(); };\n  const leave = () =\u003e { pointer = null; hide(); };\n  container.addEventListener('pointermove', move);\n  container.addEventListener('pointerleave', leave);\n  const events = ['open', 'animation', 'zoom', 'pan', 'resize'];\n  events.forEach(name =\u003e viewer.addHandler(name, update));\n  update();\n  return () =\u003e {\n    container.removeEventListener('pointermove', move);\n    container.removeEventListener('pointerleave', leave);\n    events.forEach(name =\u003e viewer.removeHandler(name, update));\n    svg.remove();\n    regions.forEach(region =\u003e region.tooltip.remove());\n  };\n}\n\nfunction clearAnnotations() {\n    annotationDisposers.forEach(dispose =\u003e dispose());\n    annotationDisposers = [];\n    document.getElementById(`annotations-${id}`)?.replaceChildren();\n}\n\nfunction renderAnnotations() {\n        const annotationsLayer = document.getElementById(`annotations-${id}`);\n    \n    if (!annotationsLayer || !viewer) return;\n    if (!currentAnnotations.length) {\n        clearAnnotations();\n        return;\n    }\n\n    clearAnnotations();\n    annotationDisposers.push(renderPolygonAnnotations({\n        viewer, container: viewerContainer, layer: annotationsLayer, groups: currentAnnotations\n    }));\n\n    currentAnnotations.forEach((group, groupIndex) =\u003e {\n        if (!group.points || !Array.isArray(group.points)) return;\n\n        \n        const groupColor = group.color || '#ff4444';\n        \n\n        group.points.forEach((point, pointIndex) =\u003e {\n            const marker = document.createElement('div');\n            marker.className = 'annotation-marker';\n            marker.dataset.groupId = group.id;\n            marker.dataset.pointIndex = pointIndex;\n\n            \n            marker.style.borderColor = groupColor;\n            marker.style.boxShadow = `0 0 8px ${groupColor}80`; \n\n            const tooltip = document.createElement('div');\n            tooltip.className = 'annotation-tooltip';\n            tooltip.style.borderLeftColor = groupColor;             \n            const currentLang = document.documentElement.lang || 'ru';\n            const label = group.labels?.[currentLang] || group.labels?.ru || group.label || 'Объект';\n            const description = group.description?.[currentLang] || group.description?.ru || group.description || '';\n            \n            tooltip.innerHTML = `\n                \u003cstrong\u003e${label}\u003c/strong\u003e\u003cbr\u003e\n                ${description}\n            `;\n\n\nfunction updateMarkerPosition() {\n        \n    try {\n     \n        const tiledImage = viewer.world.getItemAt(0);\n        \n     \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        \n\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n      \n        const screenPoint = viewer.viewport.viewportToViewerElementCoordinates(viewportPoint);\n        \n\n        if (screenPoint \u0026\u0026 !isNaN(screenPoint.x) \u0026\u0026 !isNaN(screenPoint.y)) {\n            marker.style.left = screenPoint.x + 'px';\n            marker.style.top = screenPoint.y + 'px';\n            \n\n            tooltip.style.left = (screenPoint.x + 12) + 'px';\n            tooltip.style.top = (screenPoint.y + 12) + 'px';\n   \n            const zoom = viewer.viewport.getZoom();\n            const baseSize = 40;\n            const zoomFactor = Math.min(Math.max(zoom / 3, 0.3), 3); \n            const markerSize = baseSize * zoomFactor;\n            \n            marker.style.width = markerSize + 'px';\n            marker.style.height = markerSize + 'px';\n            marker.style.borderWidth = Math.max(1, 2 * zoomFactor) + 'px';\n        } else {\n            console.log('X', screenPoint);\n        }\n        \n    } catch (error) {\n        console.log('XX', error);\n    }\n}\n\n\nmarker.addEventListener('click', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n              \n        viewer.viewport.panTo(viewportPoint, true);\n        viewer.viewport.zoomTo(8, null, true);\n    }\n});\n\n\n\n\nlet touchStartZoom = 1;\nlet touchStartDistance = 0;\n\nmarker.addEventListener('touchstart', (e) =\u003e {\n    if (e.touches.length === 2) {\n        e.preventDefault();\n        e.stopPropagation();\n        \n        \n        touchStartZoom = viewer.viewport.getZoom();\n        touchStartDistance = Math.hypot(\n            e.touches[0].clientX - e.touches[1].clientX,\n            e.touches[0].clientY - e.touches[1].clientY\n        );\n    }\n}, { passive: false });\n\n\n\nmarker.addEventListener('wheel', (e) =\u003e {\n    e.preventDefault();\n    e.stopPropagation();\n    e.stopImmediatePropagation();\n    \n    if (viewer \u0026\u0026 viewer.viewport \u0026\u0026 viewer.world.getItemAt(0)) {\n        const tiledImage = viewer.world.getItemAt(0);\n        const viewport = viewer.viewport;\n        \n        const imagePoint = new OpenSeadragon.Point(\n            point.x * tiledImage.source.dimensions.x,\n            point.y * tiledImage.source.dimensions.y\n        );\n        const viewportPoint = tiledImage.imageToViewportCoordinates(imagePoint);\n        \n\n        const zoomFactor = e.deltaY \u003e 0 ? 0.9 : 1.1;\n        \n \n        \n \n        viewer.viewport.zoomBy(zoomFactor, viewportPoint);\n        \n \n        setTimeout(updateScaleBar, 100);\n    }\n}, { passive: false });\n\n\n\n\n         \n            marker.addEventListener('click', (e) =\u003e {\n                e.stopPropagation();\n                if (viewer) {\n                    viewer.viewport.panTo(\n                        new OpenSeadragon.Point(point.x, point.y),\n                        true\n                    );\n                    viewer.viewport.zoomTo(8);\n                }\n            });\n\n            annotationsLayer.appendChild(marker);\n            annotationsLayer.appendChild(tooltip);\n            \n            updateMarkerPosition();\n            \n \n            viewer.addHandler('zoom', updateMarkerPosition);\n            viewer.addHandler('pan', updateMarkerPosition);\n            viewer.addHandler('resize', updateMarkerPosition);\n            viewer.addHandler('animation', updateMarkerPosition);\n            annotationDisposers.push(() =\u003e {\n                ['zoom', 'pan', 'resize', 'animation'].forEach(name =\u003e {\n                    viewer.removeHandler(name, updateMarkerPosition);\n                });\n            });\n        });\n    });\n    \n\n}\n\n\n\n    function toggleAnnotations() {\n    showAnnotations = !showAnnotations;\n    const button = document.getElementById(`toggle-annotations-${id}`);\n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n\n  \n    updateAnnotationButtonText();\n\n    if (showAnnotations) {\n        button.classList.add('active');\n        if (currentAnnotations.length \u003e 0) {\n            renderAnnotations();\n        } else {\n            setTimeout(() =\u003e {\n                showAnnotations = false;\n                updateAnnotationButtonText();\n                button.classList.remove('active');\n            }, 1000);\n        }\n    } else {\n        button.classList.remove('active');\n        \n\n        if (viewer \u0026\u0026 annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n}\n\n\nfunction initialize() {\n    \n    if (typeof OpenSeadragon === 'undefined') {\n        console.log('OpenSeadragon еще не загружен, ждем...');\n        setTimeout(initialize, 100);\n        return;\n    }\n\n    initOpenSeadragon();\n    if (!singleMode) {\n        initSpecimenButtons();\n    }\n\n    const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n    \n    if (toggleBtn) {\n        showAnnotations = false;\n        updateAnnotationButtonText();\n        toggleBtn.classList.remove('active');\n        \n        toggleBtn.addEventListener('click', toggleAnnotations);\n    } else {\n        console.log('XXX');\n    }\n\n    let resizeTimeout;\n    window.addEventListener('resize', function() {\n        clearTimeout(resizeTimeout);\n        resizeTimeout = setTimeout(() =\u003e {\n            if (viewer \u0026\u0026 currentSpecimen) {\n                updateScaleBar();\n            }\n        }, 250);\n    });\n\n    if (specimens.length \u003e 0) {\n        setTimeout(() =\u003e loadSpecimen(0), 500);\n    }\n}\n\n\n\n\n\n\n\nfunction compactClampZoom(value) {\n    return Math.max(1, Math.min(50, value));\n}\n\nfunction applyCompactInitialZoom() {\n    if (!compactMode || !viewer || !viewer.viewport) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    compactLastWidth = width;\n    \n    \n    const zoom = viewer.viewport.getZoom(true);\n    const targetZoom = compactClampZoom(zoom * 700 / width);\n    viewer.viewport.zoomTo(targetZoom, null, true);\n    updateScaleBar();\n}\n\nfunction handleCompactResize() {\n    if (!compactMode || !viewer || !viewer.viewport || !currentSpecimen) return;\n    const width = viewerContainer.getBoundingClientRect().width;\n    if (!(width \u003e 0)) return;\n    if (compactLastWidth \u003e 0 \u0026\u0026 Math.abs(width - compactLastWidth) \u003e 0.5) {\n        \n        const previousWidth = compactLastWidth;\n        compactLastWidth = width;\n        const zoom = viewer.viewport.getZoom(true);\n        viewer.viewport.zoomTo(compactClampZoom(zoom * previousWidth / width), null, true);\n    } else {\n        compactLastWidth = width;\n    }\n    updateScaleBar();\n}\n\nfunction updateScaleBar() {\n    \n    \n    \n    \n    const REFERENCE_SCOPE_WIDTH = 700;\n    \n    \n    \n    \n    const GLOBAL_SCALE_CORRECTION = 149 / 154; \n    const barLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n    const barText = document.getElementById(`scale-bar-text-${id}`);\n    if (!barLine || !barText) return;\n\n    const hideBar = () =\u003e {\n        barLine.style.visibility = 'hidden';\n        barText.textContent = '—';\n    };\n\n    if (!viewer || !viewer.viewport || !viewer.world ||\n        !viewer.world.getItemAt(0) || !currentSpecimen) {\n        hideBar();\n        return;\n    }\n\n    const legacyMPP = Number(currentSpecimen.microns_per_pixel);\n    const imageMPP = Number(currentSpecimen.image_microns_per_pixel);\n    const scopeWidth = viewerContainer.getBoundingClientRect().width;\n    \n    const zoom = viewer.viewport.getZoom(true);\n\n    if ((!((legacyMPP \u003e 0) \u0026\u0026 Number.isFinite(legacyMPP)) \u0026\u0026\n         !((imageMPP \u003e 0) \u0026\u0026 Number.isFinite(imageMPP))) ||\n        !(scopeWidth \u003e 0) || !(zoom \u003e 0) ||\n        !Number.isFinite(scopeWidth) || !Number.isFinite(zoom)) {\n        hideBar();\n        return;\n    }\n\n    \n    \n    \n    \n    const micronsPerScreenPx =\n        imageMPP \u003e 0 \u0026\u0026 Number.isFinite(imageMPP)\n            ? imageMPP / viewer.world.getItemAt(0).viewportToImageZoom(zoom)\n            : (legacyMPP / zoom) * (REFERENCE_SCOPE_WIDTH / scopeWidth) * GLOBAL_SCALE_CORRECTION;\n\n    \n    \n    const maxWidthPx = scopeWidth * 0.30;\n    const maxMicrons = maxWidthPx * micronsPerScreenPx;\n    if (!(maxMicrons \u003e 0) || !Number.isFinite(maxMicrons)) {\n        hideBar();\n        return;\n    }\n\n    const power = Math.pow(10, Math.floor(Math.log10(maxMicrons)));\n    let shownMicrons = power;\n    for (const factor of [1, 2, 5, 10]) {\n        if (factor * power \u003c= maxMicrons) {\n            shownMicrons = factor * power;\n        }\n    }\n    const lineWidth = shownMicrons / micronsPerScreenPx;\n    if (!(lineWidth \u003e 0) || !Number.isFinite(lineWidth)) {\n        hideBar();\n        return;\n    }\n\n    barLine.style.width = `${lineWidth}px`;\n    barLine.style.visibility = 'visible';\n    const display = value =\u003e Number(value.toPrecision(5)).toString();\n    const inMillimeters = currentSpecimen.calibration_unit === 'mm' ||\n        (!currentSpecimen.calibration_unit \u0026\u0026 shownMicrons \u003e= 1000);\n    barText.textContent = inMillimeters\n        ? `${display(shownMicrons / 1000)} mm`\n        : `${display(shownMicrons)} µm`;\n}\n\n    function playLensEffect(isZoomIn) {\n        if (isTransitioning) return;\n        \n        isTransitioning = true;\n        \n        \n        lensEffect.className = 'lens-effect';\n        lensChromatic.className = 'lens-chromatic';\n        lensFlare.className = 'lens-flare';\n        \n        \n        setTimeout(() =\u003e {\n            \n            if (isZoomIn) {\n                lensEffect.classList.add('lens-focus-in');\n                lensChromatic.classList.add('chromatic-in');\n                lensFlare.classList.add('flare-in');\n            } else {\n                lensEffect.classList.add('lens-focus-out');\n                lensChromatic.classList.add('chromatic-out');\n                lensFlare.classList.add('flare-out');\n            }\n            \n            \n            \n            \n            setTimeout(() =\u003e {\n                isTransitioning = false;\n            }, 800);\n        }, 50);\n    }\n\n\n\n    function handleZoomChange(newZoom) {\n        lastZoomLevel = currentZoomLevel;\n        currentZoomLevel = newZoom;\n        \n        \n        const zoomThreshold = 0.2;\n        const zoomChange = Math.abs(newZoom - lastZoomLevel) / lastZoomLevel;\n        \n        if (zoomChange \u003e= zoomThreshold) {\n            const isZoomIn = newZoom \u003e lastZoomLevel;\n            playLensEffect(isZoomIn);\n        }\n        \n        \n        updateScaleBar();\n    }\n\n\n    function initOpenSeadragon() {\n        \n        if (!viewerContainer) {\n            console.error('Контейнер DZI viewer не найден');\n            return;\n        }\n\n        try {\n            viewer = OpenSeadragon({\n                id: \"dzi-viewer-\" + id,\n                prefixUrl: \"\",\n                showNavigator: false,\n                navigatorSizeRatio: 0.15,\n                showZoomControl: false,\n                showHomeControl: false,\n                showFullPageControl: false,\n                animationTime: 0.8,\n                blendTime: 0.3,\n                minZoomLevel: 1,\n                maxZoomLevel: 50,\n                gestureSettingsMouse: {\n                    scrollToZoom: true\n                },\n                useCanvas: true,\n                loadTilesWithAjax: false\n            });\n\n\n            installMeasurementTool({ viewer, getSpecimen: () =\u003e currentSpecimen });\n\n            \n            \n            viewer.world.addHandler('add-item', function(event) {\n                const tiledImage = event.item;\n                tiledImage.addHandler('fully-loaded-change', function(state) {\n                    if (viewer.world.getItemAt(0) !== tiledImage) return;\n                    updateTileStatus(state.fullyLoaded);\n                });\n            });\n\n            \n            \n            function onFirstTileReady(tiledImage) {\n                if (!tiledImage || tiledImage !== viewer.world.getItemAt(0) || firstTileDrawn) return;\n                firstTileDrawn = true;\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = null;\n                hideLoader();\n                updateTileStatus(tiledImage.getFullyLoaded());\n            }\n\n            viewer.addHandler('tile-loaded', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n            viewer.addHandler('tile-drawn', function(event) {\n                onFirstTileReady(event.tiledImage);\n            });\n\n            viewer.addHandler('open', function() {\n\n                \n                \n                const openedImage = viewer.world.getItemAt(0);\n                clearTimeout(firstTileFallbackTimer);\n                firstTileFallbackTimer = setTimeout(() =\u003e {\n                    onFirstTileReady(openedImage);\n                }, 1800);\n                \n                \n                currentZoomLevel = viewer.viewport.getZoom(true);\n                lastZoomLevel = currentZoomLevel;\n                if (typeof showZoomLevelIndicator === 'function') {\n                    showZoomLevelIndicator();\n                }\n                \n                \n                \n                applyCompactInitialZoom();\n\n                \n                setTimeout(updateScaleBar, 300);\n            });\n\n            \n            viewer.addHandler('zoom', function(event) {\n                const newZoom = event.zoom;\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('animation', updateScaleBar);\n\n            \n            viewer.addHandler('animation-finish', function(event) {\n                const newZoom = viewer.viewport.getZoom(true);\n                handleZoomChange(newZoom);\n            });\n\n            \n            viewer.addHandler('resize', function() {\n                handleCompactResize();\n                updateScaleBar();\n            });\n\n            viewer.addHandler('open-failed', function(event) {\n                console.error('Ошибка загрузки DZI:', event.message);\n                loaderText.textContent = 'Loading failed';\n                resetTileStatus();\n                setTimeout(hideLoader, 2000);\n                isTransitioning = false;\n            });\n\n        } catch (error) {\n            console.error('Ошибка инициализации OpenSeadragon:', error);\n            isTransitioning = false;\n        }\n    }\n\n\n    function initSpecimenButtons() {\n        specimens.forEach((specimen, index) =\u003e {\n            const button = document.createElement('button');\n            button.className = 'specimen-btn';\n            const imageHolder = document.createElement('div');\n            imageHolder.className = 'specimen-btn-image-container';\n            const image = document.createElement('img');\n            image.className = 'specimen-btn-image';\n            image.src = specimen.buttonImage;\n            image.alt = specimen.previewAlt || specimen.name;\n            image.onerror = () =\u003e { image.style.display = 'none'; };\n            imageHolder.appendChild(image);\n            const label = document.createElement('div');\n            label.className = 'specimen-btn-text';\n            label.textContent = specimen.name;\n            button.append(imageHolder, label);\n            button.dataset.specimenId = index;\n            \n            \n            \n            \n            button.addEventListener('click', () =\u003e {\n                loadSpecimen(index);\n            });\n\n            const card = document.createElement('div');\n            card.className = 'fossa-specimen-card';\n            card.appendChild(button);\n            if (specimen.pageUrl) {\n                const link = document.createElement('a');\n                link.className = 'fossa-specimen-page-link';\n                link.href = specimen.pageUrl;\n                link.textContent = 'Specimen page';\n                link.setAttribute('aria-label', link.textContent + ': ' + specimen.name);\n                card.appendChild(link);\n            }\n            specimenButtons.appendChild(card);\n        });\n    }\n\n\nfunction normalizeSlideKey(value) {\n    return String(value || '')\n        .trim()\n        .replace(/^\\/+/, '')\n        .replace(/^dzi\\//i, '')\n        .replace(/\\.dzi$/i, '')\n        .toLowerCase();\n}\n\n\nfunction getSpecimenIdFromUrl() {\n    const params = new URLSearchParams(window.location.search);\n    \n    \n    const requestedSlide = shortcodeSlide || params.get('slide');\n\n    if (!requestedSlide) {\n        return 0;\n    }\n\n    const requestedKey = normalizeSlideKey(requestedSlide);\n\n    const specimenId = specimens.findIndex(specimen =\u003e\n        normalizeSlideKey(specimen.dzi) === requestedKey\n    );\n\n    if (specimenId \u003c 0) {\n        console.warn(\n            'Microscope slide not found:',\n            requestedSlide,\n            'available:',\n            specimens.map(s =\u003e normalizeSlideKey(s.dzi))\n        );\n        return 0;\n    }\n\n    return specimenId;\n}\n\n\nfunction updateSpecimenUrl(specimen) {\n    if (!specimen || !specimen.dzi) return;\n\n    \n    if (singleMode) return;\n\n    const url = new URL(window.location.href);\n\n    \n\n    url.searchParams.set(\n        'slide',\n        normalizeSlideKey(specimen.dzi)\n    );\n\n    window.history.replaceState(\n        { slide: specimen.dzi },\n        '',\n        url\n    );\n}\n\n\n\nfunction loadSpecimen(specimenId) {\n    const specimen = specimens[specimenId];\n    if (!specimen) return;\n\n\n    showAnnotations = false;\n    updateAnnotationButtonText();\nconst toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n\nif (toggleBtn) {\n    toggleBtn.classList.remove('active');\n\n    const hasAnnotations =\n        specimen.roi_file \u0026\u0026\n        specimen.roi_file !== '\"\"' \u0026\u0026\n        specimen.roi_file.trim() !== '';\n\n    toggleBtn.style.display = hasAnnotations ? 'block' : 'none';\n}\n\n    \n    const annotationsLayer = document.getElementById(`annotations-${id}`);\n    if (annotationsLayer) {\n        clearAnnotations();\n    }\n    currentAnnotations = [];\n\n    \n    document.querySelectorAll(`#specimen-buttons-${id} .specimen-btn`).forEach(btn =\u003e {\n        btn.classList.remove('active');\n    });\n    const activeButton = document.querySelector(`#specimen-buttons-${id} [data-specimen-id=\"${specimenId}\"]`);\n    if (activeButton) activeButton.classList.add('active');\n\n    \n    \n    \n    if (specimenName) {\n        specimenName.textContent = specimen.name;\n    }\n    if (specimenDesc) {\n        specimenDesc.textContent = specimen.description;\n    }\n\n    currentSpecimen = specimen;\n    updateSpecimenUrl(specimen);\n    \n    \n \n    \n    if (specimen.roi_file \u0026\u0026 specimen.roi_file !== '\"\"' \u0026\u0026 specimen.roi_file !== '') {\n        loadAnnotations(specimen.roi_file);\n    } else {\n\n        currentAnnotations = [];\n        if (annotationsLayer) {\n            clearAnnotations();\n        }\n    }\n    \n    \n    loadDZIPanorama(specimen.dzi);\n}\n\n\n    function loadDZIPanorama(dziFile) {\n        resetTileStatus();\n        \n        const oldScaleLine = document.querySelector(`#scale-bar-${id} .scale-bar-line`);\n        const oldScaleText = document.getElementById(`scale-bar-text-${id}`);\n        if (oldScaleLine) oldScaleLine.style.visibility = 'hidden';\n        if (oldScaleText) oldScaleText.textContent = '—';\n        loaderText.textContent = 'Loading image…';\n        showLoader();\n\n        if (!viewer) {\n            console.error('OpenSeadragon viewer не инициализирован');\n            return;\n        }\n\n        const dziPath = \"/dzi/\" + dziFile;\n        viewer.open(dziPath);\n    }\n\n    function showLoader() {\n        loader.style.display = 'flex';\n    }\n\n    function hideLoader() {\n        loader.style.display = 'none';\n    }\n\n\n    function initialize() {\n\n        \n        if (typeof OpenSeadragon === 'undefined') {\n            setTimeout(initialize, 100);\n            return;\n        }\n\n        initOpenSeadragon();\n        if (compactMode \u0026\u0026 typeof ResizeObserver !== 'undefined') {\n            \n            \n            const compactResizeObserver = new ResizeObserver(() =\u003e {\n                requestAnimationFrame(handleCompactResize);\n            });\n            compactResizeObserver.observe(viewerContainer);\n        }\n        if (!singleMode) {\n            initSpecimenButtons();\n        }\n\n        const toggleBtn = document.getElementById(`toggle-annotations-${id}`);\n        \n        if (toggleBtn) {\n            toggleBtn.addEventListener('click', toggleAnnotations);\n            console.log('YYYYY');\n        } else {\n            console.log('XXXXX');\n        }\n\n        let resizeTimeout;\n        window.addEventListener('resize', function() {\n            clearTimeout(resizeTimeout);\n            resizeTimeout = setTimeout(() =\u003e {\n                if (viewer \u0026\u0026 currentSpecimen) {\n                    updateScaleBar();\n                }\n            }, 250);\n        });\n\nif (specimens.length \u003e 0) {\n    const initialSpecimenId = getSpecimenIdFromUrl();\n\n    setTimeout(() =\u003e {\n        loadSpecimen(initialSpecimenId);\n    }, 500);\n}\n    }\n\n    if (document.readyState === 'loading') {\n        document.addEventListener('DOMContentLoaded', initialize);\n    } else {\n        initialize();\n    }\n\n\n})();\n\u003c/script\u003e","title":"Yellowtail kidney — tubular destruction"}]