/* Mobile presentation and phone study previews. */
body.mobile-layout #settings-panel label:has(input[data-setting="showLanguage"]),
body.mobile-layout #settings-panel label:has(input[data-setting="showContrast"]),
body.mobile-layout #settings-panel label:has(input[data-setting="showSfx"]),
body.mobile-layout #settings-mesh-inspector,
body.mobile-layout #mesh-inspector {display:none!important;}
body.mobile-layout #language-control,body.mobile-layout #sfx-toggle,body.mobile-layout #theme-toggle,body.mobile-layout #tree-memory-button {display:none!important;}
@media (pointer:coarse) and (max-width:950px) {
 body:not(.mobile-layout) #language-control,body:not(.mobile-layout) #sfx-toggle,body:not(.mobile-layout) #theme-toggle,body:not(.mobile-layout) #tree-memory-button {display:none!important;}
}
body.mobile-layout #image-sources {display:none !important;}
/* Palette sits halfway between the stem's right edge and the lower photos.
   Keep draw/maximize alongside it, clear of the bottom safe area. */
body.mobile-layout #paint-tree-toggle {left:calc(var(--mobile-palette-x,75vw) - 21px);right:auto;bottom:calc(8px + env(safe-area-inset-bottom));}
body.mobile-layout #mesh-draw-toggle {left:calc(var(--mobile-palette-x,75vw) - 71px);right:auto;bottom:calc(8px + env(safe-area-inset-bottom));}
body.mobile-layout #mobile-fullscreen-toggle {left:auto;right:calc(6px + env(safe-area-inset-right));top:calc(3px + env(safe-area-inset-top));bottom:auto;margin:0;}
@media (orientation:portrait){
 body.mobile-layout #paint-tree-toggle,
 body.mobile-layout #mesh-draw-toggle {left:auto;right:calc(6px + env(safe-area-inset-right));}
 body.mobile-layout #paint-tree-toggle {bottom:calc(8px + env(safe-area-inset-bottom));}
 body.mobile-layout #mesh-draw-toggle {bottom:calc(58px + env(safe-area-inset-bottom));}
 body.mobile-layout #phone-toolbar .phone-row-search {display:flex!important;flex-wrap:nowrap;}
 body.mobile-layout #phone-toolbar .phone-row-search .search-container {flex:1 1 0!important;width:auto!important;max-width:none;order:0;}
 body.mobile-layout #phone-toolbar #species-search-actions {flex:0 0 84px;width:84px;order:0;align-self:auto;}
 body.mobile-layout #phone-toolbar #mobile-fullscreen-toggle {position:static;flex:0 0 40px;width:40px;height:40px;margin:0;}
 body.mobile-layout #phone-toolbar .phone-row-tools {flex-wrap:nowrap;align-items:flex-start;}
 body.mobile-layout .phone-row-tools .generation-actions {min-width:0;}
 body.mobile-layout .phone-row-tools #display-controls {flex:0 0 auto;}
}
body.mobile-layout #mesh-xy-control,
body.mobile-layout .tree-interaction-guides,
body.mobile-layout .stem-drag-hint,
body.mobile-layout .stem-outline-overlay,
body.mobile-layout .mesh-gesture-preview {display:none!important;}
body.mobile-layout #paint-tree-toggle,body.mobile-layout #mesh-draw-toggle,body.mobile-layout #mobile-fullscreen-toggle {transition:background .15s,border-color .15s;}
/* Slide zoom is app-owned and preserves DOM fullscreen. */
body.mobile-layout #detail-copy-lower,
body.mobile-layout #detail-conservation-status {display:none!important;}
body.mobile-layout #detail-tree-position {display:none!important;}
body.mobile-layout #detail-info-row {grid-template-columns:minmax(0,1fr) 36px;}
body.mobile-layout #image-detail.fullscreen #detail-copy {margin-bottom:0;}
body.mobile-layout #detail-copy-upper {flex:1 1 auto;overflow:visible;}
body.mobile-layout #image-detail #detail-context-visuals {margin-top:14px;flex:0 0 auto;}
body.mobile-layout #detail-summary {cursor:pointer;}
body.mobile-layout #wiki-content {cursor:zoom-out;}
@media (orientation:landscape){
 body.mobile-layout #canvas-container {touch-action:none;}
 body.mobile-layout #image-detail.fullscreen #detail-copy {grid-template-rows:minmax(0,1fr) 120px;}
}
body.mobile-layout #image-detail,body.mobile-layout #image-detail * {touch-action:none;}
body.mobile-layout #wiki-modal,body.mobile-layout #wiki-modal * {touch-action:auto;}
#slide-zoom-viewport {display:contents;}
body.mobile-layout #slide-zoom-viewport {display:none;position:fixed;inset:0;overflow:hidden;background:#030303;z-index:10000000;touch-action:none;}
body.mobile-layout #slide-zoom-viewport:has(#image-detail.visible) {display:block;}
body.mobile-layout #slide-zoom-viewport #image-detail {position:absolute;left:0;top:0;transform-origin:0 0;}
body.mobile-layout #slide-zoom-viewport:has(#image-detail.detail-transitioning) {background:transparent;}
@media (orientation:portrait){
 body.mobile-layout #slide-zoom-viewport #image-detail.visible.fullscreen {height:auto;min-height:100dvh;max-height:none;overflow:visible;}
}
body.mobile-layout #wiki-modal {inset:10px;transform:none;width:auto;max-width:none;max-height:calc(100dvh - 20px);box-sizing:border-box;overflow:auto;z-index:10000020;padding:20px;font-size:17px;line-height:1.6;}
body.mobile-layout #wiki-modal h3 {padding-right:35px;font-size:21px;line-height:1.3;}
body.mobile-layout #wiki-modal.slide-summary-reader #wiki-content {font-size:21px;}
body.mobile-layout #wiki-modal.slide-summary-reader h3 {font-size:31.5px;}
body.mobile-layout #wiki-close {position:absolute;top:4px;right:0;font:inherit;border:0;background:transparent;padding:4px 8px;}
@media (orientation:portrait) {
 body.mobile-layout #image-detail.visible.fullscreen {inset:0;transform:none;width:100dvw;height:100dvh;max-height:100dvh;padding:10px 0 18px;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:max-content clamp(220px,46dvh,560px) max-content max-content max-content max-content max-content;grid-template-areas:none;align-content:start;gap:10px;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;}
 body.mobile-layout #image-detail.fullscreen #detail-copy,body.mobile-layout #detail-copy-upper {display:contents;}
 body.mobile-layout #detail-names {grid-column:1;grid-row:1;flex-direction:column;align-items:center;gap:3px;padding:0 44px;}
 body.mobile-layout #detail-common {font-size:22px;line-height:1.2;}
 body.mobile-layout #detail-scientific {font-size:14px;line-height:1.3;}
 body.mobile-layout #detail-media {grid-area:auto;grid-column:1;grid-row:2;width:100%;height:100%;min-height:0;margin:0;}
 body.mobile-layout #detail-image {width:100%;height:100%;min-height:0;object-fit:contain;}
 body.mobile-layout #detail-credit {grid-column:1;grid-row:3;position:static;max-width:none;margin:0;padding:0 10px;font-size:10px;}
 body.mobile-layout #detail-info-row {grid-column:1;grid-row:4;flex:none;min-height:0;margin:0;padding:0 12px;}
 body.mobile-layout #detail-summary-stack {display:block;}
 body.mobile-layout #image-detail #detail-summary,body.mobile-layout #image-detail #detail-summary.summary-overflowing:hover {position:static;inset:auto;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:4;line-clamp:4;flex:none;min-height:0;max-height:6em;overflow:hidden;text-overflow:ellipsis;font-size:21px;line-height:1.5;padding:0;box-shadow:none;background:transparent;}
 body.mobile-layout #image-detail #detail-controls {grid-area:auto;grid-column:1;grid-row:5;display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;justify-content:center;gap:12px;padding:0 10px;overflow:visible;}
 body.mobile-layout #detail-controls-upper {flex-direction:row;gap:8px;}
 body.mobile-layout #detail-close {position:absolute;top:10px;right:8px;z-index:8;background:#111b;}
 body.mobile-layout #image-detail #detail-share-button {flex-direction:row;align-items:center;gap:3px;margin:0;font-size:22px;}
 body.mobile-layout #image-detail.fullscreen #detail-links {flex-direction:row;flex-wrap:wrap;gap:12px;margin:0;font-size:24px;}
 body.mobile-layout #detail-context-visuals {grid-column:1;grid-row:6;gap:10px;margin:0 10px;}
 body.mobile-layout #detail-range-map-image {max-height:180px;}
 body.mobile-layout #detail-copy-lower {grid-column:1;grid-row:7;display:flex;flex-direction:column;gap:10px;min-height:0;overflow:visible;padding:0 12px;}
 body.mobile-layout #detail-photo-rating {bottom:4px;left:8px;height:auto;}
 body.mobile-layout #detail-find-images {background:#111b;font-size:12px;}
 body.mobile-layout #detail-tree-position {display:none;}
}
body.mobile-layout #detail-keep-species, body.mobile-layout #detail-discard-species { display:none !important; }
/* Reserve half the close button's exact width above it, rather than letting
   a tall upper controls stack centre itself partly outside the screen. */
body.mobile-layout #detail-controls { --slide-button-size:30px; display:flex; flex-direction:column; justify-content:flex-start; align-items:center; gap:0; padding-top:calc(var(--slide-button-size) / 2); padding-bottom:5px; box-sizing:border-box; overflow-y:auto; }
body.mobile-layout #detail-controls-upper { flex:none; align-self:auto; gap:3px; order:0; }
body.mobile-layout #detail-controls .detail-view-control { width:var(--slide-button-size); height:var(--slide-button-size); line-height:var(--slide-button-size); }
/* Screen controls share one fixed top-right pair in either orientation. */
body.mobile-layout #image-detail #detail-close {position:absolute;top:calc(6px + env(safe-area-inset-top));right:env(safe-area-inset-right,0px);z-index:10;background:#111b;}
body.mobile-layout #image-detail #detail-maximize {position:absolute;top:calc(6px + env(safe-area-inset-top));right:calc(34px + env(safe-area-inset-right));z-index:10;background:#111b;font-size:24px;}
body.mobile-layout #image-detail #detail-names {padding-right:72px;}
body.mobile-layout #image-detail #detail-summary {font-size:21px;}
body.mobile-layout #detail-share-button { order:1; flex:none; align-self:center; margin:8px 0 0; }
body.mobile-layout #image-detail #detail-links { order:2; flex:none; align-self:center; margin:16px 0 0; gap:5px; }
/* The species links and neighbour explorer form one group beside Share. */
body.mobile-layout #detail-species-actions {display:flex;flex-direction:row;align-items:center;justify-content:space-evenly;gap:6px;order:2;}
body.mobile-layout #image-detail #detail-species-actions #detail-links {display:contents;}
body.mobile-layout #detail-neighbourhood {display:inline-flex;align-items:center;justify-content:center;}
@media (orientation:landscape){
 body.mobile-layout #image-detail #detail-species-actions {grid-row:3;flex-direction:column;width:100%;gap:8px;}
}
body.mobile-layout #neighbourhood-toggle {display:none!important;}
body.mobile-layout.neighbourhood-view #canvas-container {touch-action:none;}
body.mobile-layout.neighbourhood-view .internal-node {width:4px;height:4px;}
body.mobile-layout #neighbourhood-browser {top:auto;bottom:5px;right:5px;width:110px;padding:5px;font-size:10px;line-height:1.4;}
body.mobile-layout #neighbourhood-browser nav {flex-direction:row;gap:4px;margin-top:3px;}
body.mobile-layout #neighbourhood-browser nav button {width:32px;height:30px;line-height:30px;}
body.mobile-layout #intro-test-buttons {display:none!important;}
body.mobile-layout #mobile-init-menu,body.mobile-layout #showcase-selector {display:none!important;}
#neighbourhood-close {display:none;}
body.mobile-layout.neighbourhood-view #top-generator-bar {display:none!important;}
body.mobile-layout.neighbourhood-view #mobile-fullscreen-toggle {position:fixed;left:auto;right:46px;top:calc(3px + env(safe-area-inset-top));bottom:auto;z-index:10000003;visibility:visible;}
body.mobile-layout.neighbourhood-view #neighbourhood-close {display:block;position:fixed;right:0;top:calc(3px + env(safe-area-inset-top));z-index:10000003;width:42px;height:40px;margin:0;padding:0;border:0;background:#111b;color:white;font:32px/40px sans-serif;cursor:pointer;}
body.mobile-layout.neighbourhood-view #neighbourhood-browser {top:48px;}
body.mobile-layout #neighbourhood-browser {left:auto;right:5px;bottom:auto;top:var(--mobile-toolbar-bottom,60px);}
body.mobile-layout #neighbourhood-browser #clade-links {display:flex;flex-direction:row;flex-wrap:nowrap;justify-content:space-evenly;gap:3px;font-size:18px;}
body.mobile-layout #neighbourhood-browser #clade-links a {flex:0 0 auto;}
body.mobile-layout #neighbourhood-browser #clade-detail.legend-docked {overflow:visible;max-height:none;padding:3px;}
body.mobile-layout #neighbourhood-browser #clade-summary {display:none;}
body.mobile-layout.neighbourhood-view.neighbourhood-wiki-hint #neighbourhood-browser #clade-detail #clade-summary {position:fixed;left:5px;right:5px;bottom:3px;z-index:10000002;margin:0;padding:0 3px;box-sizing:border-box;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;line-clamp:1;max-height:18px;overflow:hidden;text-overflow:ellipsis;font-size:15px;line-height:18px;background:#000c;}
@media (orientation:portrait){
 body.mobile-layout #neighbourhood-browser {left:auto;right:5px;}
 body.mobile-layout.neighbourhood-view .phone-row-tools,body.mobile-layout.neighbourhood-view .phone-row-extras,body.mobile-layout.neighbourhood-view #vary-picker {display:none!important;}
 body.mobile-layout.neighbourhood-view.neighbourhood-wiki-hint #neighbourhood-browser #clade-detail #clade-summary {-webkit-line-clamp:2;line-clamp:2;max-height:36px;}
 body.mobile-layout #image-detail #detail-controls {display:grid;grid-template-columns:minmax(0,2fr) minmax(0,1fr);gap:10px 0;}
 body.mobile-layout #detail-controls-upper {grid-column:1/-1;grid-row:1;}
 body.mobile-layout #detail-species-actions {grid-column:1;grid-row:2;width:100%;}
 body.mobile-layout #image-detail #detail-share-button {grid-column:2;grid-row:2;justify-self:center;margin:0;}
}
body.phone-study #top-search-tools,body.phone-study #sfx-toggle,body.phone-study #theme-toggle,body.phone-study #ui-panel,body.phone-study #status-panel { display:none !important; }
body.phone-study:not(.phone-rarity) #conservation-control { display:none !important; }
body.phone-study #top-generator-bar { height:auto; min-height:0; background:#111e; pointer-events:none; }
body.phone-study #phone-toolbar { padding:6px; display:flex; flex-direction:column; gap:5px; pointer-events:auto; }
body.phone-study .phone-row { display:flex; align-items:center; gap:5px; min-width:0; flex-wrap:wrap; }
body.phone-study .phone-row-search .search-container { flex:1 1 150px; min-width:0; }
body.phone-study #in-search { width:100%; height:40px; box-sizing:border-box; font-size:16px; }
body.phone-study #species-search-actions { flex:0 0 84px; width:84px; }
body.phone-study #btn-generate { width:100%; height:40px; padding:4px; font-size:11px; margin:0; }
body.phone-study #search-numeric-controls { margin:0; gap:5px; flex:0 0 auto; }
body.phone-study .top-slider-control { margin:0; width:26px; min-width:0; gap:1px; }
body.phone-study .top-slider-control label { font-size:9px; text-align:center; margin:0; }
body.phone-study .slider-group { width:26px; grid-template-columns:26px; margin:0; }
body.phone-study .slider-group input { width:26px; height:25px; box-sizing:border-box; margin:0; }
body.phone-study .generation-actions { display:flex; align-items:center; gap:3px; flex:1 1 auto; flex-wrap:wrap; margin:0; width:auto; }
body.phone-study .generation-actions button { margin:0; height:36px; min-width:30px; padding:3px; touch-action:manipulation; }
body.phone-study #btn-map-search { width:42px; }
body.phone-study #btn-random { width:48px; }
body.phone-study #tree-share-button { width:62px; min-width:62px; gap:2px; }
body.phone-study #tree-share-button .share-icons { font-size:16px; }
body.phone-study #tree-share-button .share-label { font-size:9px; }
body.phone-study #display-controls { position:static; display:flex; align-items:center; gap:5px; margin-left:auto; }
body.phone-study #display-controls button { height:35px; min-width:36px; padding:3px; }
body.phone-study #tree-memory-button { display:none !important; }
body.phone-study #language-current-code { display:none; }
body.phone-study #display-controls #language-button { width:38px; min-width:38px; padding:3px; display:grid; grid-template-columns:1fr; gap:0; }
body.phone-study #language-current-flag { display:block; line-height:0; font-size:26px; }
body.phone-study .mobile-language-flag { display:block; width:30px; height:23px; object-fit:contain; }
body.phone-study #language-menu .mobile-language-flag { width:24px; height:18px; }
body.phone-study #vary-picker { position:relative; flex:0 0 32px; width:32px; margin:0; }
body.phone-study #vary-picker .picker-label { display:none; }
body.phone-study #vary-toggle { width:32px; height:35px; padding:0; }
body.mobile-layout #settings-backdrop {z-index:10000009;}
body.mobile-layout #feedback-backdrop {z-index:10000011;}
body.mobile-layout #feedback-panel {z-index:10000012;max-height:calc(100dvh - 16px);overflow-y:auto;}
body.mobile-layout #settings-panel {position:fixed;inset:8px;transform:none;width:auto;height:calc(100dvh - 16px);max-height:calc(100dvh - 16px);margin:0;padding:12px;box-sizing:border-box;overflow:hidden;display:flex;flex-direction:column;gap:10px;z-index:10000010;font-size:14px;}
body.mobile-layout #settings-panel[hidden] {display:none;}
body.mobile-layout #settings-panel .settings-heading-row {flex:none;margin:0;min-height:42px;}
body.mobile-layout #settings-heading {font-size:24px;}
body.mobile-layout #settings-close {margin:0;width:42px;height:42px;padding:0;}
body.mobile-layout .mobile-settings-content {display:grid;grid-template-columns:minmax(0,1fr);gap:14px;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding-right:3px;}
body.mobile-layout .mobile-settings-general,body.mobile-layout .mobile-settings-extras {min-width:0;}
body.mobile-layout #settings-panel .settings-options {max-width:none;margin:0;}
body.mobile-layout #settings-panel label {min-width:0;min-height:38px;font-size:14px;line-height:1.35;white-space:normal;overflow-wrap:anywhere;}
body.mobile-layout #settings-panel input[type=checkbox] {width:20px;height:20px;}
body.mobile-layout #settings-panel select {min-width:0;max-width:100%;width:100%;font-size:16px;min-height:38px;box-sizing:border-box;}
body.mobile-layout #settings-panel .settings-control-row {grid-template-columns:minmax(0,1fr) minmax(90px,120px);gap:6px 10px;padding:8px 0;margin:0;border-bottom:1px solid #7775;}
body.mobile-layout #settings-panel .settings-control-row > label,body.mobile-layout #settings-panel .settings-control-row > span {font-size:14px;}
body.mobile-layout #settings-panel .settings-control-row > .settings-display-toggle {grid-column:1/-1;justify-content:flex-start;gap:8px;min-height:30px;}
body.mobile-layout #settings-panel .settings-language-row {grid-template-columns:repeat(2,minmax(0,1fr));}
body.mobile-layout #settings-panel .settings-language-row > label:first-child {grid-column:1/-1;}
body.mobile-layout #settings-panel .settings-control-row button {min-height:38px;font-size:14px;margin:0;}
body.mobile-layout #settings-panel .settings-tree-history {margin:10px 0;padding:8px 0;}
body.mobile-layout #settings-panel .settings-tree-history-note {display:block;font-size:12px;}
body.mobile-layout #settings-panel .settings-search-hover-row {display:block;margin:8px 0;}
body.mobile-layout #settings-panel .settings-search-hover-options {display:flex;flex-wrap:wrap;gap:6px 16px;}
body.mobile-layout #settings-panel .settings-outlinks {margin:0;padding:10px;border:1px solid #7776;border-radius:8px;}
body.mobile-layout #settings-panel .settings-search-row {display:flex;flex-direction:column;align-items:stretch;gap:5px;margin:8px 0;}
body.mobile-layout #settings-panel .settings-search-sources {display:flex;flex-wrap:wrap;gap:4px 12px;}
body.mobile-layout #settings-panel #settings-video-optional {display:flex;flex-direction:column;align-items:stretch;width:100%;}
body.mobile-layout #settings-panel #phone-study-options {margin-top:12px;padding:10px;border:1px solid #7776;border-radius:8px;}
body.mobile-layout #settings-panel #phone-study-options h3 {margin:0 0 6px;font-size:16px;}
body.mobile-layout #settings-panel #phone-study-options > label {flex-wrap:wrap;}
body.mobile-layout #settings-panel #settings-feedback-open {white-space:normal;min-height:42px;font-size:14px;margin-top:12px;}
@media (orientation:portrait) {
 body.mobile-layout #settings-panel {inset:6px;height:calc(100dvh - 12px);max-height:calc(100dvh - 12px);padding:12px;}
 body.mobile-layout .mobile-settings-content {grid-template-columns:minmax(0,1fr);}
}
@media (orientation:landscape) {
 body.mobile-layout #settings-panel {inset:6px 10px;height:calc(100dvh - 12px);max-height:calc(100dvh - 12px);padding:8px 12px;gap:6px;}
 body.mobile-layout .mobile-settings-content {grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:18px;align-items:start;}
 body.mobile-layout .mobile-settings-extras {border-left:1px solid #7776;padding-left:16px;}
}
body.phone-study #phone-study-options { padding:8px 0; border-top:1px solid #555; }
body.phone-study #phone-study-options label { display:flex; gap:8px; padding:5px 0; }
body.phone-study #map-search-dialog { max-width:calc(100vw - 12px); box-sizing:border-box; }
#map-touch-hint {display:none;}
/* Desktop map: place the complete controls beside a larger landscape map. */
body:not(.mobile-layout) #map-search-dialog {width:min(1440px,calc(100vw - 48px));height:min(800px,calc(100vh - 48px));display:grid;grid-template-columns:minmax(0,min(480px,42%)) minmax(0,1fr);grid-template-rows:auto auto auto minmax(0,1fr) auto auto;gap:8px 16px;overflow:hidden;}
body:not(.mobile-layout) #map-search-toolbar {grid-column:1;grid-row:1;margin:0;min-width:0;}
body:not(.mobile-layout) #map-place-form {grid-template-columns:minmax(0,1fr) 70px;}
body:not(.mobile-layout) #map-lifeform-row {grid-template-columns:minmax(0,1fr) 40px;}
body:not(.mobile-layout) #map-specify-word {grid-column:1/-1;width:100%;box-sizing:border-box;}
body:not(.mobile-layout) #map-filter-row {grid-column:1;grid-row:2;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto auto;align-items:start;gap:20px;margin:0;min-width:0;}
body:not(.mobile-layout) #map-conservation-filter {grid-column:1;grid-row:1;width:100%;min-width:0;}
body:not(.mobile-layout) #map-conservation-categories {justify-content:center;width:100%;}
body:not(.mobile-layout) #map-conservation-categories button {width:min(31px,14%);height:44px;}
body:not(.mobile-layout) #map-conservation-categories .conservation-circle {width:26px;height:26px;font-size:12px;}
body:not(.mobile-layout) #map-conservation-categories [aria-checked="true"] .conservation-circle {width:38px;height:38px;font-size:17px;}
body:not(.mobile-layout) #map-conservation-filter .conservation-modes {justify-content:center;gap:10px;}
body:not(.mobile-layout) #map-conservation-filter .conservation-modes button {height:40px;padding:0 14px;font-size:21px;}
body:not(.mobile-layout) .map-mobile-precarity-label {display:block;min-height:16px;line-height:16px;text-align:center;font-size:13px;margin-bottom:3px;}
body:not(.mobile-layout) #map-filter-row #map-radius-control {grid-column:1;grid-row:2;display:grid;grid-template-columns:auto minmax(0,1fr);width:100%;height:auto;gap:10px;margin:0;}
body:not(.mobile-layout) .map-mobile-radius-label {display:none;}
body:not(.mobile-layout) #map-radius-value {white-space:nowrap;}
body:not(.mobile-layout) #map-radius-value::before {content:'Radius = ';}
body:not(.mobile-layout) #map-radius-slider {width:100%;min-width:0;}
body:not(.mobile-layout) #map-search-status {grid-column:1;grid-row:3;margin:0;}
body:not(.mobile-layout) #map-search-progress {grid-column:1;grid-row:4;min-width:0;overflow:auto;}
body:not(.mobile-layout) #map-photo-bias-host {grid-column:1;grid-row:4;min-height:0;overflow:hidden;align-self:stretch;}
body:not(.mobile-layout) #map-photo-bias-host #map-photo-bias-show {display:block;width:max-content;min-width:0;margin:0 auto 5px;padding:3px 8px;font-size:12px;}
body:not(.mobile-layout) #map-specify-panel {width:100%;min-width:0;}
.map-desktop-group-label {display:none;}
body:not(.mobile-layout) label[for="map-specify-word"]:not(.map-desktop-group-label) {display:none;}
body:not(.mobile-layout) .map-desktop-group-label {display:block;}
body:not(.mobile-layout) #map-photo-bias-host #photo-bias-editor {display:none;gap:12px;padding-top:4px;height:calc(100% - 32px);box-sizing:border-box;min-height:0;}
body:not(.mobile-layout) #map-photo-bias-host.expanded #photo-bias-editor {display:flex;}
body:not(.mobile-layout) #map-photo-bias-host .photo-bias-column {min-height:0;gap:3px;align-items:center;font-size:12px;}
body:not(.mobile-layout) #map-photo-bias-host .photo-bias-column > span {flex:none;text-align:center;line-height:1.2;}
body:not(.mobile-layout) #map-photo-bias-host .photo-bias-plot {flex:0 1 auto;height:clamp(45px,calc(100vh - 540px),250px);max-height:calc(100% - 35px);}
body:not(.mobile-layout) #map-photo-bias-host #photo-bias-canvas,body:not(.mobile-layout) #map-photo-bias-host #photo-bias-inspector {height:100%;}
body:not(.mobile-layout) #map-photo-bias-host .photo-bias-explanation {display:flex;flex-wrap:wrap;align-content:start;align-items:center;gap:6px;}
body:not(.mobile-layout) #map-photo-bias-host .photo-bias-explanation > p:first-child {font-size:0;margin:0;flex-basis:100%;}
body:not(.mobile-layout) #map-photo-bias-host .photo-bias-explanation > p:first-child::after {content:'How this works';font-size:12px;text-decoration:underline;cursor:pointer;}
body:not(.mobile-layout) #map-photo-bias-host .photo-bias-explanation > p:first-child:is(:hover,:focus)::before {content:attr(data-map-hint);position:fixed;left:clamp(16px,8vw,150px);bottom:clamp(16px,8vh,80px);z-index:10000030;width:min(520px,calc(100vw - 48px));box-sizing:border-box;padding:16px;border:1px solid #777;border-radius:6px;background:#202124;color:#fff;box-shadow:0 5px 20px #0009;font:400 16.5px/1.35 'Segoe UI',sans-serif;text-decoration:none;pointer-events:none;}
body:not(.mobile-layout) #map-photo-bias-host #photo-bias-readout,body:not(.mobile-layout) #map-photo-bias-host #photo-bias-state {flex-basis:100%;margin:0;}
body:not(.mobile-layout) #map-photo-bias-host #photo-bias-reset,body:not(.mobile-layout) #map-photo-bias-host #photo-bias-toggle {display:inline-block;width:auto;height:auto;margin:0;padding:3px 6px;border:1px solid #888;background:transparent;color:inherit;font-size:11px;}
body:not(.mobile-layout) #map-photo-bias-host #photo-bias-toggle[aria-pressed="true"] {background:#285b86;}
body:not(.mobile-layout) #map-search-status {font-size:0;min-height:0;}
body:not(.mobile-layout) #map-search-status:not(:empty) {font-size:12px;}
body:not(.mobile-layout) #map-search-progress:not([hidden]) {grid-row:5;}
body.mobile-layout #map-photo-bias-host {display:none;}
#mobile-map-photos{display:none}
body.mobile-layout #mobile-map-photos{display:block;border-top:1px solid #666;margin-top:10px;padding-top:10px;width:100%;font-size:11px}
body.mobile-layout #map-filter-row #map-radius-control{border-top:1px solid #666;margin-top:10px;padding-top:10px}
body.mobile-layout #map-radius-control .map-mobile-radius-label{display:none}
.map-photo-scale{display:flex;align-items:center;justify-content:space-between;gap:3px;color:white}
.map-photo-scale>span:nth-child(2){font:22px/1 Arial,sans-serif}
#mobile-map-photos input{width:100%;margin:6px 0}
#mobile-map-photos output{display:block;font-size:11px;color:#ccc}
.map-photo-actions{display:flex;justify-content:space-between;align-items:center;margin-top:5px}
.map-photo-actions button{padding:4px 7px;font-size:11px;background:transparent;color:inherit;border:1px solid #666;border-radius:3px}
.map-photo-actions .map-photo-help{border:0;text-decoration:underline;padding-left:0}
.map-photo-toggle[aria-pressed=true]{background:#a3e635;color:#000}
body:not(.mobile-layout) #map-search-stage,body:not(.mobile-layout) #map-photo-preview {grid-column:2;grid-row:1/-1;width:100%;height:100%;min-height:0;}
body:not(.mobile-layout) #map-species-log {grid-column:1;grid-row:5;margin:0;max-height:70px;overflow:auto;}
body:not(.mobile-layout) #map-attribution {grid-column:1;grid-row:6;text-align:left;}
/* Mobile map: scrollable controls left; uninterrupted touch map right. */
body.mobile-layout #map-search-dialog {width:100dvw;max-width:none;height:100dvh;max-height:none;margin:0;border-radius:0;padding:7px;display:grid;grid-template-columns:clamp(170px,28vw,270px) minmax(0,1fr);grid-template-rows:auto auto auto 1fr auto auto;gap:7px;overflow:hidden;}
body.mobile-layout #map-search-toolbar {grid-column:1;grid-row:1;margin:0;min-width:0;gap:5px;}
body.mobile-layout #map-place-form,body.mobile-layout label[for="map-place-input"] {display:none;}
body.mobile-layout .map-step-label {font-size:13px;}
body.mobile-layout #map-lifeform-row {display:grid;grid-template-columns:minmax(0,1fr) 38px;gap:5px;}
body.mobile-layout #map-specify-word {grid-column:1/-1;width:100%;min-width:0;height:38px;box-sizing:border-box;font-size:16px;}
body.mobile-layout #map-find-species {width:100%;min-width:0;font-size:13px;white-space:normal;padding:5px;}
body.mobile-layout #map-specify-button {width:38px;min-width:0;}
body.mobile-layout #map-filter-row {grid-column:1;grid-row:2;display:flex;flex-direction:column;align-items:stretch;gap:8px;min-width:0;}
body.mobile-layout #map-conservation-filter {font-size:11px;}
.map-mobile-precarity-label {display:none;}
body.mobile-layout .map-mobile-precarity-label {display:block;text-align:center;font-size:13px;line-height:16px;min-height:16px;margin-bottom:3px;}
body.mobile-layout #map-filter-row #map-radius-control {width:100%;flex:auto;margin:0;gap:5px;}
.map-mobile-radius-label {display:none;}
body.mobile-layout #map-filter-row #map-radius-control {display:grid;grid-template-columns:auto minmax(0,1fr);height:auto;}
body.mobile-layout .map-mobile-radius-label {display:block;grid-column:1/-1;height:16px;}
body.mobile-layout #map-radius-value {white-space:nowrap;}
body.mobile-layout #map-radius-value::before {content:'Radius = ';}
body.mobile-layout #map-radius-slider {width:100%;min-width:0;}
body.mobile-layout #map-search-status {grid-column:1;grid-row:3;font-size:12px;overflow-wrap:anywhere;max-height:70px;overflow:auto;}
body.mobile-layout #map-search-progress {grid-column:1;grid-row:4;min-width:0;}
body.mobile-layout #map-progress-row {display:block;}
body.mobile-layout #map-progress-meter {font-size:8px;}
body.mobile-layout #map-search-stage,body.mobile-layout #map-photo-preview {grid-column:2;grid-row:1/-1;width:100%;height:100%;min-height:0;}
body.mobile-layout #map-search-stage {display:flex;flex-direction:column;}
body.mobile-layout #map-search-stage[hidden] {display:none;}
body.mobile-layout #map-touch-hint {display:flex;flex-direction:column;flex:none;align-items:flex-start;padding:2px 42px 5px 4px;color:inherit;font-size:13px;line-height:1.3;}
body.mobile-layout #map-search-canvas {flex:1 1 auto;}
@media (orientation:landscape) {body.mobile-layout #map-touch-hint {padding-left:54px;}}
body.mobile-layout #map-species-log {grid-column:1;grid-row:5;max-height:60px;overflow:auto;font-size:11px;}
body.mobile-layout #map-attribution {grid-column:1;grid-row:6;font-size:9px;}
body.mobile-layout #map-search-close {top:9px;right:10px;background:#111c;z-index:1100;}
body.mobile-layout #map-specify-panel {max-height:160px;overflow:auto;}
/* Portrait is a separate layout: full-width map first, controls underneath.
   Keep the existing left-controls/right-map arrangement in landscape. */
@media (orientation:portrait) {
 body.mobile-layout #map-search-overlay {padding:0;}
 body.mobile-layout #map-search-dialog {grid-template-columns:minmax(0,1fr);grid-template-rows:clamp(240px,50dvh,560px) auto auto auto auto auto auto;align-content:start;overflow-y:auto;}
 body.mobile-layout #map-search-stage,body.mobile-layout #map-photo-preview {grid-column:1;grid-row:1;}
 body.mobile-layout #map-search-toolbar {grid-column:1;grid-row:2;}
 body.mobile-layout #map-filter-row {grid-column:1;grid-row:3;}
 body.mobile-layout #map-search-status {grid-column:1;grid-row:4;margin:0;}
 body.mobile-layout #map-search-progress {grid-column:1;grid-row:5;}
 body.mobile-layout #map-species-log {grid-column:1;grid-row:6;}
 body.mobile-layout #map-attribution {grid-column:1;grid-row:7;}
}
body.phone-study #intro-test-buttons { display:flex !important; flex-direction:row; gap:0; left:2px; top:auto; bottom:28px; width:auto; padding:0; background:transparent; }
body.phone-study #intro-test-buttons button { width:22px; min-width:0; height:18px; padding:0; margin:0; border-radius:0; font-size:9px; }
body.phone-study #intro-test-buttons small,body.phone-study #intro-test-status { display:none; }
body.phone-study[data-phone-layout="bottom"] .phone-row-extras { position:fixed; bottom:4px; left:6px; right:6px; padding:4px; background:#111e; }
body.phone-study[data-phone-layout="search-first"] .phone-row-search { display:contents; }
body.phone-study[data-phone-layout="search-first"] .phone-row-search .search-container { order:-2; flex:0 0 40px; width:100%; }
body.phone-study[data-phone-layout="search-first"] #species-search-actions { align-self:flex-end; order:0; flex:0 0 40px; }
body.phone-study[data-phone-layout="search-first"] .phone-row-tools { order:1; }
body.phone-study[data-phone-layout="search-first"] .phone-row-extras { order:2; }
body:not(.phone-study) #phone-study-options,body:not(.phone-study) #mobile-init-menu { display:none; }
body.phone-study #intro-test-buttons { display:none !important; }
body.phone-study #mobile-init-menu { position:fixed; left:2px; top:var(--mobile-toolbar-bottom,140px); z-index:16; font:11px/1.3 system-ui; color:white; background:#161616e6; }
body.phone-study #mobile-init-menu summary { cursor:pointer; padding:3px 5px; }
body.phone-study #mobile-init-menu #intro-test-buttons { display:flex !important; position:static; flex-direction:column; }
body.phone-study #mobile-init-menu #intro-test-buttons button { width:44px; height:24px; }
body.phone-study #tree-name-overlay .node-name:not(.neighbour-name) { font-size:11px; pointer-events:none; }
body:not(.mobile-layout) #mobile-photo-names { display:none; }
#mobile-photo-names { position:fixed; left:50%; top:var(--mobile-name-y,50%); width:calc(100vw - 24px); height:0; z-index:16; pointer-events:none; }
.mobile-photo-name { position:absolute; left:0; top:0; width:100%; transform:translate(-50%,-50%); opacity:0; text-align:center; color:white; font:500 18px/1.35 'Segoe UI',sans-serif; text-shadow:0 1px 3px #000,0 0 5px #000; }
/* Photo fitting uses the image rectangle, not desktop label padding/baselines. */
/* Old landscape renderer dimensions / hidden labels must not enlarge the
   browser's portrait layout viewport while orientation is changing. */
body.mobile-layout #canvas-container {position:fixed;inset:0;width:auto;height:auto;overflow:hidden;contain:layout size paint;}
body.mobile-layout #canvas-container > canvas,body.mobile-layout #canvas-container > div {max-width:100%;max-height:100%;}
body.mobile-layout #tree-name-overlay {position:fixed;inset:0;width:100%;height:100%;overflow:clip;contain:layout paint;}
#mobile-fullscreen-toggle {display:none;position:fixed;right:112px;bottom:32px;width:42px;height:42px;padding:0;border:1px solid #aaa;border-radius:7px;background:#13131bd9;color:white;z-index:110;font:28px/1 Arial,sans-serif;cursor:pointer;}
.mobile-layout #mobile-fullscreen-toggle {display:block;}
@media (orientation:landscape){
 body.mobile-layout #phone-toolbar #settings-button{position:fixed;top:calc(3px + env(safe-area-inset-top));right:calc(6px + env(safe-area-inset-right));left:auto;bottom:auto;width:40px;height:40px;z-index:112;display:block!important}
 body.mobile-layout #mobile-fullscreen-toggle{right:calc(50px + env(safe-area-inset-right))}
 body.mobile-layout #phone-toolbar{padding-right:90px;box-sizing:border-box}
}
body.mobile-layout #conservation-control{margin-left:0;flex:0 0 auto;order:0}
body.mobile-layout #conservation-button{font-size:24px;background:transparent}
.mobile-fullscreen-message {position:fixed;left:10px;right:10px;bottom:85px;z-index:1000;padding:9px;background:#222e;color:white;font:14px system-ui;text-align:center;border-radius:6px;}
body.mobile-layout .node-label:not(.neighbour-dot) { padding:0; gap:0; line-height:0; }
body.mobile-layout .node-img { display:block; }
body.mobile-layout .node-img:not(.img-loading):hover { transform:none; }
@media (orientation:landscape) {
 body.phone-study #phone-toolbar { flex-direction:row; flex-wrap:nowrap; align-items:center; gap:4px; }
 body.phone-study .phone-row { display:contents !important; }
 body.phone-study .phone-row-search .search-container,
 body.phone-study[data-phone-layout="search-first"] .phone-row-search .search-container { flex:0 1 220px; width:220px; min-width:110px; max-width:220px; order:0; }
 body.phone-study #species-search-actions,body.phone-study[data-phone-layout="search-first"] #species-search-actions { flex:0 0 70px; width:70px; align-self:auto; order:0; }
 body.phone-study #btn-generate { height:36px; }
 body.phone-study #in-search { height:36px; font-size:14px; }
 body.phone-study #search-numeric-controls { gap:4px; }
 body.phone-study .generation-actions { flex:0 0 auto; flex-wrap:nowrap; gap:3px; }
 body.phone-study #display-controls { position:static; flex:0 0 auto; gap:4px; margin:0; }
 body.phone-study #vary-picker { flex:0 0 28px; width:28px; }
 body.phone-study #vary-toggle { width:28px; }
 body.phone-study #display-controls #settings-button { width:38px; min-width:38px; }
 /* Approved landscape layout 1: one compact top strip on every phone. */
 body.phone-study #phone-toolbar {gap:3px;padding:3px;}
 body.phone-study #in-search {width:138px;height:32px;font-size:12px;}
 body.phone-study #species-search-actions {flex-basis:68px;width:68px;}
 body.phone-study #btn-generate {height:32px;font-size:10px;}
 body.phone-study .phone-row {gap:3px;}
 body.phone-study .phone-row-search .search-container,
 body.phone-study[data-phone-layout="search-first"] .phone-row-search .search-container {flex:0 1 138px;width:138px;max-width:138px;}
 body.phone-study #top-generator-bar {padding-left:env(safe-area-inset-left);padding-right:env(safe-area-inset-right);}
}

/* Keep lower slide content in the same pannable surface as the photo. */
body.mobile-layout #slide-zoom-viewport #image-detail.visible.fullscreen {max-height:none;overflow:visible;}
body.mobile-layout #image-detail #detail-context-visuals {margin-top:4px;gap:6px;align-items:start;padding-top:32px;}
/* Reserve real columns for the portrait search and corner controls. Narrow
   phones must shrink the input instead of painting Maximize over Find Species. */
@media (orientation:portrait) {
 body.phone-study #phone-toolbar .phone-row-search {display:grid!important;grid-template-columns:minmax(0,1fr) 84px 40px;align-items:center;gap:5px;min-width:0;}
 body.phone-study #phone-toolbar .phone-row-search .search-container {grid-column:1;min-width:0;width:100%!important;max-width:none;}
 body.phone-study #phone-toolbar .phone-row-search #species-search-actions {grid-column:2;min-width:0;width:84px;max-width:84px;}
 body.phone-study #phone-toolbar .phone-row-search #mobile-fullscreen-toggle {position:static!important;grid-column:3;justify-self:end;left:auto;right:auto;top:auto;width:40px;height:40px;margin:0;}
 body.phone-study #phone-toolbar .phone-row-tools {display:grid;grid-template-columns:max-content minmax(0,1fr) 40px;align-items:start;gap:4px;min-width:0;}
 body.phone-study #phone-toolbar .phone-row-tools #search-numeric-controls {grid-column:1;min-width:0;}
 body.phone-study #phone-toolbar .phone-row-tools .generation-actions {grid-column:2;min-width:0;margin:0;}
 body.phone-study #phone-toolbar .phone-row-tools #display-controls {position:static;grid-column:3;justify-self:end;width:40px;min-width:0;margin:0;}
 body.phone-study #phone-toolbar .phone-row-tools #settings-control,
 body.phone-study #phone-toolbar .phone-row-tools #settings-button {width:40px;min-width:40px;}
}
body.mobile-layout #detail-context-visuals #detail-conservation-badge {width:28px;height:28px;font-size:13px;left:3px;top:0;}
body.mobile-layout #detail-conservation-callout {top:17px;left:38px;font-size:16px;}
body.mobile-layout #detail-range-map {padding:2px;margin:0;}
body.mobile-layout #detail-mini-tree {padding:2px;margin:0;}
@media(orientation:portrait){
 body.mobile-layout #image-detail.visible.fullscreen {row-gap:6px;padding-bottom:calc(12px + env(safe-area-inset-bottom));}
 body.mobile-layout #image-detail #detail-controls {grid-template-rows:auto auto;row-gap:4px;padding-top:0;padding-bottom:0;}
 body.mobile-layout #image-detail #detail-controls-upper {min-height:30px;}
 body.mobile-layout #image-detail #detail-context-visuals {margin:2px 10px 0;}
}
@media(orientation:landscape){
 body.mobile-layout #slide-zoom-viewport #image-detail.visible.fullscreen {height:auto;min-height:100dvh;padding:8px 8px 24px;grid-template-rows:minmax(calc(100dvh - 32px),auto);align-content:start;gap:8px;}
 body.mobile-layout #image-detail.fullscreen #detail-copy {grid-template-rows:max-content max-content;align-content:start;gap:4px;overflow:visible;margin-bottom:0;}
 body.mobile-layout #detail-copy-upper {gap:4px;overflow:visible;}
 body.mobile-layout #image-detail #detail-media {height:calc(100dvh - 32px);align-self:start;}
 body.mobile-layout #detail-image {min-height:0;object-position:center bottom;}
 body.mobile-layout #detail-credit {top:calc(100dvh - 22px);bottom:auto;right:8px;font-size:10px;max-width:58vw;}
 body.mobile-layout #detail-controls {align-self:start;overflow:visible;}
}

/* The portrait toolbar has exactly two rows. The extras row only holds
   desktop-only controls, and must not reserve a third strip. */
@media (orientation:portrait) {
 body.phone-study #phone-toolbar .phone-row-extras {display:none!important;}
 body.phone-study #phone-toolbar .phone-row-tools {position:relative;display:flex;flex-wrap:nowrap;gap:3px;align-items:center;padding-right:43px;box-sizing:border-box;}
 body.phone-study #phone-toolbar .phone-row-tools .generation-actions {flex:0 1 auto;min-width:0;flex-wrap:nowrap;gap:3px;}
 body.phone-study #phone-toolbar .phone-row-tools #display-controls {position:absolute;right:0;top:0;display:flex;visibility:visible;opacity:1;width:40px;min-width:40px;margin:0;}
 body.phone-study #phone-toolbar .phone-row-tools #settings-control {display:block;visibility:visible;opacity:1;flex:0 0 40px;}
 body.phone-study #phone-toolbar .phone-row-tools #settings-button {
  width:40px;height:40px;min-width:40px;margin:0;padding:0;
  border:1px solid #aaa;border-radius:7px;
  background:#13131bd9;color:#fff;box-shadow:none;font-size:24px;
 }
 body.phone-study #phone-toolbar .phone-row-tools #settings-button span {
  display:block;filter:none;font-size:24px;line-height:1;
 }
}
body.phone-study #btn-random .fruit-reel {font-size:11px;}
body.phone-study #random-group-icon {font-size:19px;}
@media (orientation:landscape) {
 body.mobile-layout #paint-tree-toggle {left:auto;right:calc(6px + env(safe-area-inset-right));bottom:calc(8px + env(safe-area-inset-bottom));}
}
body.mobile-layout #settings-panel #mobile-reading-size {display:flex;align-items:center;gap:10px;margin:8px 0 14px;}
body.mobile-layout #mobile-reading-size label {flex:0 0 auto;}
body.mobile-layout #mobile-reading-size input {flex:1 1 auto;min-width:0;}
body.mobile-layout #mobile-reading-size-preview {display:inline-block;flex:0 0 36px;text-align:center;line-height:1.2;}
body.mobile-layout #image-detail #detail-summary,
body.mobile-layout #image-detail #detail-summary.summary-overflowing:hover,
body.mobile-layout #wiki-modal.slide-summary-reader #wiki-content {font-size:calc(21px * var(--mobile-reading-scale, 1) * var(--slide-summary-scale, 1));}
body.mobile-layout #detail-scientific {font-size:calc(20px * var(--mobile-reading-scale, 1));}
body.mobile-layout #detail-credit {font-size:15px;}
@media (orientation:portrait) {
 body.mobile-layout #detail-scientific {font-size:calc(14px * var(--mobile-reading-scale, 1));}
}

/* Advanced map space: retain control sizes and reserve the lower right for options. */
body:not(.mobile-layout) #map-search-dialog.map-advanced-open #map-search-stage {height:50%;align-self:start;}
#map-search-stage #map-attribution {position:absolute;right:4px;bottom:2px;z-index:500;margin:0;padding:2px 4px;background:rgba(255,255,255,.85);color:#333;font-size:9px;pointer-events:none;}
body:not(.mobile-layout) #map-advanced-info:not([hidden]) {grid-column:2;grid-row:1/-1;align-self:end;height:45%;box-sizing:border-box;overflow:auto;padding:12px;border-top:1px solid #777;font-size:13px;}
body:not(.mobile-layout) #map-advanced-info p {margin:8px 0;}
body:not(.mobile-layout) .map-advanced-toolbar {display:flex;align-items:center;justify-content:center;gap:8px;white-space:nowrap;font-size:12px;}
body:not(.mobile-layout) .map-advanced-toolbar #map-photo-bias-show {margin:0;}
#map-request-count {width:64px;}
#map-quantity {width:48px;}
#map-advanced-info output {display:block;margin-top:10px;}
#map-query-console {margin-top:12px;padding:10px 12px;border:1px solid #66727c;border-radius:6px;background:rgba(0,0,0,.16);font-size:13px;line-height:1.7;font-variant-numeric:tabular-nums;}
#map-query-console div:first-child {font-weight:600;}
body:not(.mobile-layout) #map-photo-bias-host #photo-bias-reset,body:not(.mobile-layout) #map-photo-bias-host #photo-bias-toggle {font-size:22px;padding:6px 12px;}
body:not(.mobile-layout) #map-photo-bias-host #photo-bias-toggle[aria-pressed="true"] {background:#a3e635;color:#000;}
body:not(.mobile-layout) .photo-bias-buttons {display:flex;gap:8px;align-items:center;}
body:not(.mobile-layout) #photo-bias-editor .photo-bias-buttons #photo-bias-reset,
body:not(.mobile-layout) #photo-bias-editor .photo-bias-buttons #photo-bias-toggle {box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;width:96px;height:48px;margin:0;padding:0;border:1px solid #888;border-radius:3px;font-size:22px;}
body:not(.mobile-layout) #photo-bias-editor .photo-bias-buttons #photo-bias-toggle[aria-pressed="true"] {background:#a3e635;color:#000;}
body:not(.mobile-layout) #map-search-dialog.map-advanced-open #map-photo-preview {height:50%;align-self:start;}
#map-photo-grid .map-photo-slot[role="button"] {cursor:pointer;}
#photo-review-status {font-size:39px;white-space:normal;overflow:visible;}

/* Triangle menu: ALL mirrors the photo-filter toggle. */
body:not(.mobile-layout) #conservation-panel .conservation-modes button[data-risk-mode="all"] {
    box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;gap:5px;
    width:96px;height:48px;padding:0;border:1px solid #888;border-radius:3px;font-size:22px;
}
#conservation-panel .conservation-modes button[data-risk-mode="all"] small {font-size:18px;line-height:1;font-weight:400;}
#conservation-panel .conservation-modes button[data-risk-mode="all"][aria-pressed="false"] {background:#a3e635;color:#000;}
#conservation-panel .conservation-modes button[data-risk-mode="all"][aria-pressed="true"] {background:transparent;color:inherit;}

body:not(.mobile-layout) #conservation-panel {grid-template-columns:82px 96px minmax(0,1fr);}

#tree-search-status {width:min(440px,92vw);padding:12px 18px;}
#tree-loading-meter {margin:8px 0 5px;display:block;text-align:center;}
#tree-loading-filters {font-size:11px;line-height:1.5;margin-top:6px;}

.tree-memory-preview img {display:block;width:100%;height:100%;object-fit:contain;}
.tree-memory-preview-pending {display:flex;align-items:center;justify-content:center;height:100%;font:12px 'Segoe UI',sans-serif;color:#aaa;}

/* Photo layouts display a local still, never a transformed live tree. */
body.photo-layout-active #canvas-container {display:none;}
.photo-layout-tree-image {display:block;width:100%;height:100%;object-fit:contain;}
.photo-layout-tree-image[hidden] {display:none;}

:is(#detail-summary,#wiki-content).curated-summary {white-space:normal;}
:is(#detail-summary,#wiki-content).curated-summary p {margin:0 0 .85em;}
:is(#detail-summary,#wiki-content).curated-summary a {color:#8fc5ff;}
:is(#detail-summary,#wiki-content).curated-summary .curated-citation-pill {display:inline-flex;align-items:center;justify-content:center;min-width:1.5em;padding:.05em .45em;margin:0 .12em;border:1px solid #7ca7d480;border-radius:999px;background:#8fc5ff20;font-size:.78em;line-height:1.45;text-decoration:none;vertical-align:baseline;}
:is(#detail-summary,#wiki-content).curated-summary .curated-citation-pill:hover {background:#8fc5ff40;}
html[data-theme="day"] :is(#detail-summary,#wiki-content).curated-summary a {color:#075aab;}

#new-device-desktop-notice {position:fixed;bottom:calc(12px + env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);z-index:2147483600;padding:8px 13px;border:1px solid #777;border-radius:6px;background:#add8e6;color:#000;font:19.5px/1.3 sans-serif;white-space:nowrap;pointer-events:none;}
body:not(.mobile-layout) #new-device-desktop-notice {display:none;}

body.mobile-first-tree-starting #loading-gallery {display:none!important;}

/* One full-height reading flow; no nested capped summary scroller. */
body.mobile-layout #wiki-modal.slide-summary-reader {inset:10px;width:auto;max-width:none;height:auto;max-height:calc(100dvh - 20px);overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;overflow-anchor:none;-webkit-overflow-scrolling:touch;}
body.mobile-layout #wiki-modal #wiki-content {display:block;max-height:none;height:auto;overflow:visible;white-space:normal;overflow-wrap:anywhere;-webkit-line-clamp:unset;line-clamp:unset;cursor:auto;}
body.mobile-layout #random-group-menu {position:fixed;left:50%;right:auto;transform:translateX(-50%);max-width:calc(100dvw - 16px);box-sizing:border-box;grid-template-columns:repeat(6,minmax(0,34px));}

/* Same compact, tap-to-read summary in both mobile orientations. */
body.mobile-layout #image-detail #detail-summary,
body.mobile-layout #image-detail #detail-summary.summary-overflowing:hover {position:static;inset:auto;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:4;line-clamp:4;flex:none;min-height:0;max-height:6em;overflow:hidden;text-overflow:ellipsis;line-height:1.5;padding:0;box-shadow:none;background:transparent;}
body.mobile-layout #wiki-modal #wiki-title {margin:0 44px 16px 0;padding-right:0;}
body.mobile-layout #wiki-modal #wiki-close {position:fixed;top:calc(14px + env(safe-area-inset-top));right:calc(14px + env(safe-area-inset-right));width:38px;height:38px;box-sizing:border-box;padding:0;z-index:2;display:grid;place-items:center;background:#1e1e1e;border-radius:4px;}
html[data-theme="day"] body.mobile-layout #wiki-modal #wiki-close {background:#fff;}

/* Independent compact photo controls, with the graph as an optional editor. */
#photo-bias-editor[hidden]{display:none!important}
#mobile-map-photos,.compact-photo-controls{display:block;width:100%;box-sizing:border-box;font-size:12px}
#mobile-map-photos{border-top:1px solid #666;margin-top:10px;padding-top:10px}
.compact-photo-controls input{width:100%;margin:6px 0}
.compact-photo-controls output{display:block;font-size:11px;color:#ccc}
.compact-photo-controls.graph-open>.map-photo-scale,.compact-photo-controls.graph-open>input,.compact-photo-controls.graph-open>output,.compact-photo-controls.graph-open>.map-photo-actions{display:none}
.compact-photo-advanced{display:block;margin:8px 0 0 auto;padding:4px 8px;background:transparent;color:inherit;border:1px solid #666;border-radius:3px;font-size:12px}
body #map-photo-bias-show{display:none!important}
body #map-filter-row{display:flex;flex-direction:column;align-items:stretch;gap:0}
body #map-filter-row #map-radius-control{display:grid;grid-template-columns:auto minmax(0,1fr);border-top:1px solid #666;margin-top:10px;padding-top:10px;width:100%;height:auto}
body:not(.mobile-layout) #map-search-dialog{grid-template-columns:clamp(230px,28vw,340px) minmax(0,1fr)}
body:not(.mobile-layout) #map-filter-row{grid-column:1;grid-row:2}
body:not(.mobile-layout) #map-photo-bias-host{grid-column:1;grid-row:4;overflow:auto}
body.mobile-layout #map-photo-bias-host.expanded{display:block;grid-column:1;grid-row:3;overflow:auto}
body #map-photo-bias-host:not(.expanded){display:none}
body #map-search-dialog.map-advanced-open #map-search-stage{height:100%!important;grid-row:1/-1}
body #map-search-dialog.map-advanced-open #map-photo-preview{height:100%!important}
#main-photo-controls{min-width:240px;padding:10px 0}
#conservation-panel #main-photo-controls{border-top:1px solid #666;margin-top:10px;padding-top:10px}
body:not(.mobile-layout) .compact-photo-advanced[aria-expanded=true]{background:#245baf;color:#fff;border-color:#5e91dc}
body.mobile-layout .compact-photo-advanced{display:none!important}
body.mobile-layout .compact-photo-controls.graph-open>.map-photo-scale,body.mobile-layout .compact-photo-controls.graph-open>.map-photo-actions{display:flex!important}
body.mobile-layout .compact-photo-controls.graph-open>input,body.mobile-layout .compact-photo-controls.graph-open>output{display:block!important}
body.mobile-layout #photo-bias-editor,body.mobile-layout #map-photo-bias-host{display:none!important}

#map-search-dialog.map-advanced-open #map-advanced-info>label{display:none}
#map-search-dialog.map-advanced-open #photo-bias-editor{display:flex;gap:8px;min-width:0;margin:0;width:100%}
#map-search-dialog.map-advanced-open .photo-bias-column{width:140px;min-width:140px}
#map-search-dialog.map-advanced-open #photo-bias-canvas{width:120px;height:120px}
#map-search-dialog.map-advanced-open .photo-bias-explanation{min-width:0;flex:1}
#map-search-dialog.map-advanced-open .photo-bias-buttons button{font-size:18px;padding:4px 6px;min-width:0}
.compact-photo-controls.graph-open>output{display:none!important}

#map-search-dialog.map-advanced-open .photo-bias-buttons{display:flex;gap:4px;flex-wrap:wrap}
#map-search-dialog.map-advanced-open .photo-bias-buttons button{font-size:18px!important;padding:4px 6px!important;min-width:0!important;width:64px!important;height:34px!important}
#map-search-dialog.map-advanced-open .photo-bias-plot{width:140px!important;height:120px!important}
#map-search-dialog.map-advanced-open #photo-bias-canvas{width:120px!important;height:120px!important}
#map-search-dialog.map-advanced-open #photo-bias-inspector{height:120px!important}
#map-conservation-filter [data-risk-mode="all"]{min-width:75px!important;white-space:nowrap;font-size:16px!important}

/* Keep the mobile precarity popup and its compact photo controls in bounds. */
body.mobile-layout #conservation-panel>div:has(#main-photo-controls){grid-column:1/-1;min-width:0;width:100%}
body.mobile-layout #conservation-panel #main-photo-controls{min-width:0;width:100%;box-sizing:border-box}
body.mobile-layout #main-photo-controls>input{display:block;width:90%;margin:8px auto;box-sizing:border-box}
body.mobile-layout #main-photo-controls .map-photo-scale,body.mobile-layout #main-photo-controls>output,body.mobile-layout #main-photo-controls .map-photo-actions{width:90%;margin-left:auto;margin-right:auto;box-sizing:border-box}
body.mobile-layout #main-photo-controls .map-photo-actions .map-photo-toggle{flex:0 0 60px;width:60px;min-width:0;margin-right:15%;padding:5px 8px}
body.mobile-layout #main-photo-controls .map-photo-help{white-space:nowrap;width:auto;min-width:0}
@media(orientation:portrait){
 body.mobile-layout #conservation-panel{position:fixed;left:8px;right:8px;top:var(--mobile-toolbar-bottom,100px);transform:none;width:calc(100dvw - 16px);max-width:none;max-height:calc(100dvh - var(--mobile-toolbar-bottom,100px) - 8px);grid-template-columns:65px 55px minmax(0,1fr);gap:12px;overflow-y:auto;overflow-x:hidden}
}
@media(orientation:landscape){
 body.mobile-layout #conservation-panel{position:fixed;top:calc(6px + env(safe-area-inset-top));bottom:calc(6px + env(safe-area-inset-bottom));height:calc(100dvh - 12px - env(safe-area-inset-top) - env(safe-area-inset-bottom));max-height:none;overflow-y:auto;overflow-x:hidden}
}

/* Titles, live selection, and compact spacing in the triangle menu. */
#conservation-panel .conservation-explainer{align-self:stretch;display:flex;flex-direction:column;justify-content:space-between;gap:12px;padding-top:0;padding-bottom:0;text-align:center}
#conservation-panel .conservation-explainer strong{align-self:stretch;text-align:center}
#conservation-selection{margin:auto 0;font-size:17px;line-height:1.3;overflow-wrap:anywhere}
#conservation-panel .conservation-explainer #conservation-facts-open{margin:0;align-self:center;text-align:center}
#conservation-panel .conservation-modes{padding-top:24px;box-sizing:border-box}
#main-photo-controls .visibility-title{display:block;text-align:center;font:600 15px/1.35 'Segoe UI',sans-serif;margin:0 0 6px}
#conservation-panel #main-photo-controls{margin-top:5px;padding-top:6px;padding-bottom:5px}
#main-photo-controls>input,body.mobile-layout #main-photo-controls>input{margin-top:4px;margin-bottom:4px}
#main-photo-controls .map-photo-actions{margin-top:2px}
#main-photo-controls .compact-photo-advanced{margin-top:4px;margin-bottom:0}

/* Center only the section heading, leaving the supporting content aligned. */
#conservation-panel>.precarity-title{grid-column:1/-1;text-align:center;font:600 15px/1.35 'Segoe UI',sans-serif;margin:0 0 2px}
#conservation-panel .conservation-explainer{text-align:left;gap:10px}
#conservation-panel .conservation-explainer #conservation-facts-open{align-self:flex-start;text-align:left}
#conservation-selection{margin:auto 0;text-align:left}
#conservation-selection:empty{display:none}
#conservation-panel .conservation-modes{padding-top:8px}

/* Selected threat colour remains visible on both toolbar layouts. */
#conservation-button[data-active="true"],
html[data-theme="day"] #conservation-button[data-active="true"],
body.mobile-layout #conservation-button[data-active="true"]{background:var(--risk-color,#453013);color:var(--risk-ink,#000);border-color:var(--risk-outline,#777)}

/* Desktop section alignment in the precarity popup. */
body:not(.mobile-layout) #conservation-panel>div:has(#main-photo-controls){grid-column:1/-1;min-width:0;width:100%}
body:not(.mobile-layout) #conservation-panel .conservation-explainer{border-left:0;border-right:1px solid #666;padding-left:28px;padding-right:12px}
body:not(.mobile-layout) #main-photo-controls .map-photo-help{font:15px/1.35 'Segoe UI',sans-serif;color:#8bc8ff;text-align:left;padding:0;border:0;background:transparent;text-decoration:underline}

body:not(.mobile-layout) #main-photo-controls .map-photo-actions{padding-left:calc(82px + 96px + 48px + 28px);box-sizing:border-box;gap:12px}
body:not(.mobile-layout) #main-photo-controls{min-width:0}

body:not(.mobile-layout) #conservation-panel .conservation-explainer{border-left:0;border-right:0}
body:not(.mobile-layout) #main-photo-controls>input{display:block;width:66.6667%;margin-left:auto;margin-right:auto}

body:not(.mobile-layout) #main-photo-controls .map-photo-scale,
body:not(.mobile-layout) #main-photo-controls>output{width:66.6667%;margin-left:auto;margin-right:auto;box-sizing:border-box}
