html[data-theme="night"] { color-scheme: dark; }
html[data-theme="day"] { color-scheme: light; }
body { margin: 0; overflow: hidden; background-color: #000; color: white; font-family: 'Segoe UI', Tahoma, sans-serif; }
        #top-generator-bar {
            position: fixed; top: 0; left: 0; right: 0; z-index: 14; height: 50px;
            box-sizing: border-box; background: rgba(18,18,18,0.76); pointer-events: none;
        }
        #top-search-tools {
            position: absolute; top: 6px; left: 6px; display: flex; align-items: center; gap: 2px;
            width: max-content; max-width: calc(100vw - 334px); pointer-events: auto;
        }
        #top-search-tools .search-container { flex: 0 0 285px; min-width: 0; }
        #top-search-tools #in-search { height: 36px; }
        #top-search-tools #btn-generate {
            flex: 0 0 88px; width: 88px; height: 36px; margin: 0; padding: 5px 4px;
            font-size: 11px; line-height: 1.1; white-space: nowrap;
        }
        .top-control-spacer { flex: 0 0 88px; width: 88px; height: 1px; }
        .top-slider-control { position: relative; flex: 0 0 110px; width: 110px; margin-right: 28px; }
        .top-slider-control > label { margin: 0 0 3px; font-size: 10px; line-height: 10px; white-space: nowrap; }
        #top-search-tools .picker-row { flex: 0 0 102px; width: 102px; margin: 0 28px 0 0; }
        #display-controls {
            position: fixed; top: 4px; right: 8px; z-index: 15;
            display: flex; align-items: center; gap: 4px;
        }
        #photo-layout-controls { display: flex; align-items: center; gap: 3px; }
        #language-control, #settings-control { position: relative; }
        #language-control[hidden], #theme-toggle[hidden], #sfx-toggle[hidden] { display: none !important; }
        #language-button, #settings-button, #theme-toggle, #sfx-toggle, #tree-memory-button, .photo-layout-button {
            display: grid; place-items: center; width: 46px; height: 42px; margin: 0; padding: 0;
            border: 0; border-radius: 6px; background: rgba(18,18,18,0.68); line-height: 1;
        }
        .photo-layout-button { width: 32px; font-size: 22px; font-weight: 400; }
        #tree-memory-button { width: 42px; font-size: 23px; }
        #tree-memory-button:disabled { opacity: 0.45; cursor: default; }
        #tree-memory-button[aria-expanded="true"] { background: #2563eb; }
        .photo-layout-button.active { color: #fff; background: #2563eb; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.65); }
        .photo-layout-button:disabled { color: #777; background: rgba(18,18,18,0.42); opacity: 0.5; cursor: default; }
        #language-button:hover, #language-button[aria-expanded="true"], #settings-button:hover, #settings-button[aria-expanded="true"], #theme-toggle:hover, #sfx-toggle:hover, #tree-memory-button:not(:disabled):hover, .photo-layout-button:not(:disabled):hover { background: rgba(35,35,35,0.9); }
        #settings-button { font-size: 27px; cursor: pointer; }
        #settings-button span { filter: drop-shadow(0 1px 1px rgba(255,255,255,0.55)); }
        #settings-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,0.55); }
        #settings-backdrop[hidden] { display: none; }
        #settings-panel {
            position: fixed; left: 50%; top: 50%; z-index: 21; transform: translate(-50%, -50%);
            width: min(66.67vw, calc(100vw - 24px)); height: min(90vh, calc(100vh - 24px));
            box-sizing: border-box; overflow-y: auto; padding: clamp(16px, 2.5vw, 38px);
            border: 1px solid #fff; border-radius: 12px; color: #fff; background: #000;
            box-shadow: 0 12px 40px rgba(0,0,0,0.6); font-size: clamp(12px, 0.94vw, 15px); line-height: 1.4;
        }
        #settings-panel[hidden], #settings-language-options[hidden] { display: none; }
        .settings-heading-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
        #settings-heading { margin: 0; font-size: clamp(21px, 2.25vw, 32px); font-weight: 650; line-height: 1.1; }
        #settings-close { width: 42px; height: 42px; flex: none; border: 1px solid currentColor; border-radius: 6px; color: inherit; background: transparent; font-size: 30px; line-height: 1; cursor: pointer; }
        #settings-close:hover { background: rgba(255,255,255,0.15); }
        .settings-options { max-width: 690px; margin-inline: auto; }
        .settings-control-row {
            display: grid; grid-template-columns: minmax(120px, 1fr) 145px 130px;
            align-items: center; gap: 20px; min-height: 42px; margin-bottom: 6px;
        }
        .settings-language-row { grid-template-columns: minmax(75px, 1fr) minmax(100px, 135px) minmax(170px, 190px) 100px; gap: 12px; }
        #settings-advanced-language-note { margin: 0 0 12px; color: #bfc8d8; font-size: 12px; }
        #settings-advanced-language-note[hidden] { display: none; }
        html[data-theme="day"] #settings-advanced-language-note { color: #38445b; }
        .settings-control-row > span, #settings-panel .settings-control-row > label {
            margin: 0; padding: 0; color: inherit; font-size: clamp(12px, 0.94vw, 15px);
        }
        .settings-control-row select, .settings-control-row button {
            width: 100%; min-height: 32px; box-sizing: border-box; padding: 4px 7px;
            border: 1px solid currentColor; border-radius: 6px; color: inherit; background: #000;
            font: inherit; font-size: clamp(11px, 0.825vw, 14px); cursor: pointer;
        }
        #settings-panel .settings-control-row > .settings-display-toggle {
            display: flex; align-items: center; justify-content: flex-end; gap: 10px;
            min-height: 32px; white-space: nowrap;
        }
        #settings-panel label {
            display: flex; align-items: center; gap: 10px; min-height: 30px;
            margin: 0; padding: 4px 0; color: inherit; font-size: clamp(12px, 0.94vw, 15px); cursor: pointer;
        }
        #settings-panel input { accent-color: #6aa9ff; width: 16px; height: 16px; flex: none; }
        .settings-tree-history { margin: 14px 0; padding: 10px 0; border-top: 1px solid rgba(255,255,255,0.25); border-bottom: 1px solid rgba(255,255,255,0.25); }
        #settings-panel .settings-tree-history > label { gap: 10px; }
        .settings-tree-history p { margin: 2px 0 0 26px; font-size: 0.86em; color: #bfc8d8; }
        #settings-tree-history-status:empty { display: none; }
        html[data-theme="day"] .settings-tree-history p { color: #38445b; }
        #settings-language-options { margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,0.35); }
        .settings-search-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; align-items: start; gap: 12px; margin-top: 16px; }
        .settings-search-row > span { padding-top: 5px; }
        .settings-search-sources { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
        #settings-panel .settings-search-sources label { display: inline-flex; gap: 6px; white-space: nowrap; }
        #settings-panel #settings-video-optional { display: flex; flex-direction: column; align-items: stretch; gap: 3px; min-width: 150px; padding: 0; }
        #settings-video-language { min-height: 30px; padding: 3px 6px; border: 1px solid currentColor; border-radius: 6px; color: inherit; background: #000; font: inherit; }
        #settings-panel [data-current-language][hidden], #settings-panel #settings-video-optional[hidden] { display: none; }
        @media (max-width: 900px) { .settings-search-row { grid-template-columns: 1fr; gap: 2px; } }
        #sfx-toggle { font-size: 11px; letter-spacing: 0.04em; }
        #sfx-toggle:not(.active) { opacity: 0.55; text-decoration: line-through; }
        #language-current-flag { font-size: 32px; line-height: 1; }
        #language-button.playful-language-symbol #language-current-flag { font-size: 21px; }
        #language-button { grid-template-columns: auto auto; width: 68px; gap: 3px; }
        #language-current-code, #theme-label { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; }
        #theme-toggle { grid-template-columns: auto auto; width: 82px; gap: 5px; padding: 0 7px; }
        #theme-icon { font-size: 25px; line-height: 1; }
        #language-menu {
            position: absolute; top: calc(100% + 4px); right: 0; width: max-content; min-width: 0;
            max-height: calc(100vh - 62px); overflow-y: auto;
            padding: 3px; border: 1px solid rgba(255,255,255,0.14); border-radius: 5px;
            background: rgba(18,18,18,0.97); box-shadow: 0 7px 20px rgba(0,0,0,0.45);
        }
        #language-menu[hidden] { display: none; }
        #language-menu button {
            display: grid; grid-template-columns: 21px max-content; align-items: center; gap: 5px;
            width: 100%; margin: 0; padding: 5px 7px; border-radius: 3px;
            background: transparent; color: #bbb; font-size: 11px; font-weight: 500; text-align: left;
        }
        #language-menu button:hover, #language-menu button[aria-selected="true"] { background: rgba(59,130,246,0.24); color: white; }
        #language-menu button span:first-child { font-size: 16px; line-height: 1; }
        #language-more { display: block !important; border-top: 1px solid rgba(255,255,255,0.25) !important; margin-top: 3px !important; text-align: center; }
        #language-more .language-more-line { display: block; width: 100%; font-size: 12px; font-weight: 400; letter-spacing: normal; line-height: normal; white-space: nowrap; text-align: center; }
        @media (max-width: 700px) {
            .settings-language-row { grid-template-columns: 1fr 1fr; }
            .settings-language-row > label:first-child { grid-column: 1 / -1; }
        }
        #canvas-container { width: 100vw; height: 100vh; position: absolute; top: 0; left: 0; z-index: 1; }
        
        .panel { background: rgba(20, 20, 20, 0.9); padding: 15px; border-radius: 8px; border: 1px solid #444; position: absolute; z-index: 10; box-shadow: 0 4px 10px rgba(0,0,0,0.5); }
        #ui-panel {
            top: 52px; bottom: 10px; left: 8px; width: 126px; padding: 4px 8px 8px;
            box-sizing: border-box; display: flex; flex-direction: column;
            background: transparent; border: 0; border-radius: 0; box-shadow: none;
            pointer-events: none;
        }
        .data-source-control { margin-top: auto; position: relative; pointer-events: auto; }
        #diagnostic-log { margin-bottom: 5px; font: 10px/1.25 system-ui, sans-serif; color: #ddd; }
        #diagnostic-log summary { cursor: pointer; padding: 4px 5px; border: 1px solid #555; border-radius: 4px; background: #202020; }
        #diagnostic-error-count { float: right; color: #ffb4b4; font-weight: 700; }
        #diagnostic-log-body {
            position: absolute; left: 0; bottom: calc(100% + 4px); width: min(370px, calc(100vw - 24px));
            max-height: min(55vh, 440px); overflow: auto; box-sizing: border-box; padding: 7px;
            border: 1px solid #777; border-radius: 6px; background: rgba(12, 15, 21, 0.97);
            box-shadow: 0 6px 18px rgba(0,0,0,0.4); color: #eee; font: 11px/1.35 system-ui, sans-serif;
        }
        .diagnostic-log-actions { display: flex; align-items: center; gap: 5px; margin-bottom: 7px; }
        .diagnostic-log-actions span { flex: 1; }
        .diagnostic-log-actions button { font: inherit; padding: 2px 5px; color: inherit; background: #303844; border: 1px solid #777; border-radius: 3px; cursor: pointer; }
        #diagnostic-log-entries { margin: 0; padding-left: 23px; }
        #diagnostic-log-entries li { margin-bottom: 8px; overflow-wrap: anywhere; }
        #diagnostic-log-entries li.diagnostic-error strong { color: #ffaaaa; }
        #diagnostic-log-entries pre { margin: 3px 0 0; white-space: pre-wrap; word-break: break-word; font: inherit; color: inherit; }
        html[data-theme="day"] #diagnostic-log { color: #111; }
        html[data-theme="day"] #diagnostic-log summary { background: #fff; border-color: #555; }
        html[data-theme="day"] #diagnostic-log-body { background: rgba(255,255,255,0.98); color: #111; border-color: #555; }
        html[data-theme="day"] .diagnostic-log-actions button { background: #f2f2f2; color: #111; }
        html[data-theme="day"] #diagnostic-log-entries li.diagnostic-error strong,
        html[data-theme="day"] #diagnostic-error-count { color: #a00000; }
        .data-source-control label { margin: 6px 0 2px; font-size: 9px; }
        #dataset-select {
            width: 100%; margin-top: 0; box-sizing: border-box; padding: 3px 4px;
            color: #ddd; background: #202020; border: 1px solid #555; border-radius: 4px;
            font: 10px/1.15 inherit; pointer-events: auto;
        }
        #dataset-select:disabled { opacity: 0.65; }
        #status-panel {
            bottom: 15px; left: 145px; width: 180px; padding: 7px 9px;
            font-size: 12px; line-height: 1.15; color: #aaa;
        }
        
        h2 { margin-top: 0; font-size: 18px; border-bottom: 1px solid #444; padding-bottom: 5px; }
        label { display: block; margin-top: 10px; font-size: 12px; color: #aaa; }
        input[type="text"], select { width: 100%; box-sizing: border-box; background: #222; border: 1px solid #555; color: white; padding: 6px; border-radius: 4px; }
        
        .search-container { position: relative; }
        #search-dropdown { display: none; position: absolute; top: 100%; left: 0; width: 100%; background: #222; border: 1px solid #555; border-top: none; border-radius: 0 0 4px 4px; max-height: 200px; overflow-y: auto; list-style: none; padding: 0; margin: 0; z-index: 100; }
        .dropdown-item { padding: 8px; cursor: pointer; border-bottom: 1px solid #333; font-size: 13px; }
        .dropdown-item:hover, .dropdown-item.active { background: #3b82f6; color: white; }
        .dropdown-msg { padding: 8px; font-size: 13px; color: #888; font-style: italic; }
        .sci-name { color: #aaa; font-size: 11px; font-style: italic; display: block; }
        .dropdown-item:hover .sci-name, .dropdown-item.active .sci-name { color: #ddd; }

        .slider-group { display: grid; grid-template-columns: minmax(0, 1fr) 34px; align-items: center; gap: 4px; margin-top: 3px; }
        .slider-group input[type="range"] { width: 100%; min-width: 0; }
        .slider-group input[type="number"] { width: 34px; box-sizing: border-box; background: #222; color: white; border: 1px solid #555; border-radius: 3px; padding: 2px; font-size: 10px; text-align: center; }
        .slider-group input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
        .slider-group input[type="number"]::-webkit-inner-spin-button,
        .slider-group input[type="number"]::-webkit-outer-spin-button { margin: 0; -webkit-appearance: none; }
        
        button { width: 100%; margin-top: 10px; padding: 10px; background: #3b82f6; border: none; color: white; cursor: pointer; font-weight: bold; border-radius: 4px; transition: 0.2s; }
        button:hover { background: #2563eb; }
        button:disabled { background: #555; cursor: not-allowed; }
        .generation-actions {
            display: flex; flex: 0 0 auto; flex-direction: row; align-items: center; gap: 2px; margin: 0 28px 0 0;
        }
        .generation-actions button {
            width: auto; min-width: 0; height: 36px; margin: 0; padding: 5px 3px;
            font-size: 10px; line-height: 1.1; white-space: nowrap;
        }
        #word-search-control { position: relative; flex: 0 0 52px; width: 52px; }
        #btn-word-search { width: 100%; }
        #word-search-menu {
            position: absolute; top: calc(100% + 5px); left: 50%; z-index: 130;
            width: min(230px, 80vw); max-height: 50vh; overflow-y: auto; padding: 7px;
            border: 1px solid #60718a; border-radius: 7px; background: #172234;
            box-shadow: 0 8px 22px rgba(0,0,0,0.45); transform: translateX(-50%);
        }
        #word-search-menu[hidden] { display: none; }
        .generation-actions #word-search-menu button {
            display: block; width: 100%; height: auto; min-height: 30px; margin: 0 0 3px;
            padding: 5px 8px; text-align: left; font-size: 12px; white-space: normal;
        }
        #word-related-groups:not(:empty) { margin-top: 5px; padding-top: 5px; border-top: 1px solid #60718a; }
        .generation-actions button span[aria-hidden="true"] { margin-right: 1px; }
        #random-group-control { position: relative; flex: 0 0 36px; width: 36px; height: 36px; }
        #random-group-button {
            width: 36px; height: 36px; margin: 0; padding: 0; font-size: 21px; line-height: 1;
            background: rgba(59,130,246,0.72); border-radius: 4px;
        }
        #random-group-button:hover, #random-group-button[aria-expanded="true"] { background: #2563eb; }
        #random-group-menu {
            position: absolute; top: calc(100% + 5px); left: 0; z-index: 120;
            display: grid; grid-template-columns: repeat(6, 34px); gap: 3px;
            width: max-content; padding: 5px; border: 1px solid rgba(255,255,255,0.2); border-radius: 6px;
            background: rgba(7,10,14,0.98); box-shadow: 0 9px 28px rgba(0,0,0,0.5);
        }
        #random-group-menu[hidden] { display: none; }
        #random-group-menu button {
            display: grid; place-items: center; width: 34px; height: 34px; margin: 0; padding: 0;
            border-radius: 4px; background: transparent; font-size: 21px; line-height: 1;
        }
        #random-group-menu button:hover, #random-group-menu button[aria-selected="true"] {
            background: rgba(59,130,246,0.38); box-shadow: inset 0 0 0 1px rgba(147,197,253,0.55);
        }
        .random-group-divider {
            grid-column: 1 / -1; height: 1px; margin: 2px 1px;
            background: rgba(255,255,255,0.18);
        }

        #map-search-overlay {
            position: fixed; inset: 0; z-index: 10000020; display: flex; align-items: center; justify-content: center;
            padding: 24px; box-sizing: border-box; background: rgba(0,0,0,0.78);
        }
        #map-search-overlay[hidden] { display: none; }
        #map-search-dialog {
            position: relative; width: min(840px, calc(100vw - 48px));
            max-height: calc(100vh - 48px); box-sizing: border-box; padding: 14px 18px 12px; overflow-y: auto; color: #ddd;
            background: rgba(8,8,8,0.97); box-shadow: 0 18px 60px rgba(0,0,0,0.62);
        }
        #map-search-close {
            position: absolute; top: 5px; right: 7px; z-index: 4; width: 36px; height: 36px; margin: 0; padding: 0;
            border-radius: 50%; background: transparent; color: #ddd; font-size: 20px; line-height: 36px;
        }
        #map-search-close:hover { background: rgba(255,255,255,0.1); }
        #map-search-stage {
            display: block;
            width: 100%; height: min(390px, calc(100vh - 230px)); min-width: 0; min-height: 0; overflow: hidden;
            position: relative; z-index: 0; contain: layout paint;
        }
        #map-search-stage[hidden], #map-photo-preview[hidden] { display: none; }
        #map-photo-preview { height: min(390px, calc(100vh - 260px)); min-height: 150px; }
        #map-photo-grid {
            display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
            grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 7px;
            width: 100%; height: 100%; overflow: hidden;
        }
        .map-photo-slot { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #19212a; border-radius: 5px; }
        .map-photo-slot img { width: 100%; height: 100%; object-fit: cover; }
        .map-photo-slot span {
            position: absolute; right: 0; bottom: 0; left: 0; padding: 14px 5px 4px;
            overflow: hidden; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,0.82));
            font-size: 11px; text-overflow: ellipsis; white-space: nowrap;
        }
        #map-search-canvas {
            position: relative; isolation: isolate; width: 100%; height: 100%;
            min-width: 0; min-height: 0; overflow: hidden; background: #15191d;
        }
        #map-radius-control {
            display: flex; align-items: center; justify-content: flex-end; gap: 10px;
            width: 50%; min-width: 0; height: 28px; margin: 0 0 5px auto;
            color: #aaa; font-size: 12px; white-space: nowrap;
        }
        #map-radius-slider {
            flex: 1; width: auto; min-width: 0; height: 22px; margin: 0; padding: 0;
            writing-mode: horizontal-tb; direction: ltr;
        }
        #map-search-toolbar {
            display: grid; grid-template-columns: minmax(0, 1fr); gap: 5px;
            margin: 0 42px 7px 0; position: relative; z-index: 1001;
        }
        .map-step-label {
            color: #eee; font: 600 20px/1.25 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
            letter-spacing: -0.015em;
        }
        #map-place-form { display: grid; grid-template-columns: minmax(0, 1fr) 104px; gap: 7px; margin: 0 0 5px; }
        #map-place-input { height: 36px; }
        #map-place-go { width: 100%; height: 36px; margin: 0; padding: 0 6px; font-size: 13px; line-height: 36px; }
        #map-lifeform-row { display: grid; grid-template-columns: minmax(0, 1fr) 132px 40px; gap: 7px; }
        #map-specify-word { min-width: 0; height: 36px; margin: 0; }
        #map-find-species, #map-specify-button { width: 100%; height: 36px; margin: 0; padding: 5px 8px; font-size: 11px; }
        #map-specify-button { padding: 0; font-size: 22px; line-height: 1; }
        #map-specify-button[aria-expanded="true"] { background: rgba(59,130,246,0.38); }
        #map-specify-panel { position: relative; z-index: 1002; width: 60%; min-width: min(100%, 280px); }
        #map-specify-panel[hidden] { display: none; }
        #map-group-menu {
            display: grid; grid-template-columns: repeat(auto-fit, minmax(34px, 1fr)); gap: 3px;
            width: 100%; box-sizing: border-box; max-height: 220px; overflow: auto; padding: 5px;
            border: 1px solid rgba(255,255,255,0.2); border-radius: 6px;
            background: rgba(7,10,14,0.98);
        }
        #map-group-menu button {
            display: grid; place-items: center; width: 34px; height: 34px; margin: 0; padding: 0;
            justify-self: center; border-radius: 4px; background: transparent; font-size: 21px; line-height: 1;
        }
        #map-group-menu button:hover, #map-group-menu button[aria-selected="true"] { background: rgba(59,130,246,0.38); }
        #map-search-progress { max-width: 100%; margin: 8px 0 5px; color: #aaa; font: 12px/1.3 "Segoe UI", sans-serif; text-align: left; }
        #map-search-progress[hidden] { display: none; }
        #map-progress-row { display: flex; align-items: center; gap: 12px; min-width: 0; margin-top: 3px; }
        #map-search-duration { color: #aaa; font-size: 12px; font-weight: normal; white-space: nowrap; }
        .map-progress-meter { color: #b8c7d8; letter-spacing: 0.5px; font: clamp(9px, 1.2vw, 12px)/1.2 Consolas, "Courier New", monospace; white-space: nowrap; }
        #map-search-status { min-height: 16px; margin: 0 52px 5px 0; color: #aaa; font-size: 12px; font-weight: normal; text-align: left; }
        #map-species-log {
            height: 69px; margin: 6px 52px 0 0; padding: 4px 6px; box-sizing: border-box;
            overflow: hidden; color: #85898d; background: rgba(0,0,0,0.22);
            font: 9px/1.35 Consolas, "Courier New", monospace;
        }
        #map-species-log[hidden] { display: none; }
        .map-species-log-entry { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .map-species-log-entry.found { color: #929a92; }
        #map-attribution { margin-top: 4px; color: #686868; font-size: 8px; text-align: right; }
        .leaflet-container { background: #111820; font-family: inherit; }
        .leaflet-control-attribution { font-size: 8px; }
        @media (max-width: 700px) {
            #map-search-overlay { padding: 8px; }
            #map-search-dialog { width: calc(100vw - 16px); padding: 10px; }
            #map-search-stage { height: min(360px, calc(100vh - 260px)); }
            #map-photo-preview { height: min(360px, calc(100vh - 285px)); }
        }
        @media (max-width: 520px) {
            #map-lifeform-row { grid-template-columns: minmax(0, 1fr) 104px 36px; gap: 4px; }
            #map-find-species { padding: 4px; }
            #map-specify-panel { width: 100%; min-width: 0; }
            #map-photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(0, 1fr)); }
            #map-progress-row { flex-wrap: wrap; gap: 2px 12px; }
        }
        @media (max-height: 650px) {
            #map-search-stage { height: max(130px, calc(100vh - 280px)); }
        }
        .picker-row {
            display: block; margin-right: 28px; color: #aaa; font-size: 10px;
        }
        #branch-style-picker { margin-top: 0; }
        #tree-shape-picker { margin-top: 0; }
        .picker-label { display: block; margin-bottom: 3px; }
        .picker-buttons { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; }
        #branch-style-picker .style-button {
            width: 18px; height: 22px; margin: 0; padding: 0; border-radius: 3px;
            background: transparent; color: #bbb; font-size: 16px; line-height: 25px;
        }
        #tree-shape-picker .shape-button {
            width: 18px; height: 22px; margin: 0; padding: 0; border-radius: 3px;
            background: transparent; color: #bbb; font-size: 19px; font-family: "Segoe UI Symbol", sans-serif; line-height: 25px;
        }
        #branch-style-picker .style-button:hover { background: rgba(59,130,246,0.25); }
        #tree-shape-picker .shape-button:hover { background: rgba(59,130,246,0.25); }
        #branch-style-picker .style-button.active {
            background: rgba(59,130,246,0.42); color: white; box-shadow: inset 0 0 0 1px rgba(147,197,253,0.7);
        }
        #tree-shape-picker .shape-button.active {
            background: rgba(59,130,246,0.42); color: white; box-shadow: inset 0 0 0 1px rgba(147,197,253,0.7);
        }
        .metal-style-icon {
            display: inline-block; width: 12px; height: 12px; vertical-align: -1px; border-radius: 50%;
            background: radial-gradient(circle at 30% 24%, #e7eaed 0 7%, #9299a1 19%, #424951 51%, #8b9198 73%, #24282d 100%);
            box-shadow: inset -1px -1px 2px rgba(0,0,0,0.7), 0 0 2px rgba(190,202,214,0.35);
        }
        .whispy-style-icon {
            display: inline-block; color: #b8d9d1; font-size: 18px; line-height: 1;
            text-shadow: 0 0 4px rgba(164,222,211,0.7), 4px 1px 4px rgba(197,168,232,0.55);
            transform: rotate(-12deg);
        }
        .smoke-style-icon {
            display: inline-block; color: #d2c3df; font-size: 18px; line-height: 1;
            text-shadow: 0 0 5px rgba(188,169,218,0.72), -3px 1px 5px rgba(157,211,204,0.48);
            transform: rotate(-8deg);
        }
        
        .status-row { display: flex; justify-content: space-between; gap: 12px; margin-top: 2px; }
        .status-row:first-child { margin-top: 0; }
        .status-good { color: #4ade80; font-weight: bold; }
        .status-bad { color: #f87171; font-weight: bold; }
        .status-warn { color: #fbbf24; font-weight: bold; }

        .node-label {
            position: relative; isolation: isolate; background: transparent; border: 0; border-radius: 10px;
            padding: 4px; color: #eee; font-size: 12px; pointer-events: auto;
            display: flex; flex-direction: column; align-items: center; gap: 6px; 
            text-align: center; box-shadow: none;
            opacity: 0; animation: popIn 0.5s forwards;
        }
        .node-photo-content {
            /* Keep depth scaling off the CSS2DObject: scaling its screen-space transform moves the leaf off its branch. */
            position: relative; display: flex; flex-direction: column; align-items: center;
            width: max-content;
        }
        @keyframes popIn { to { opacity: 1; } }
        
        /* Interactive Depth Classes */
        .node-label.hover-front { z-index: 999999 !important; }
        .node-label.zoom-front { z-index: 9999999 !important; }
        #tree-name-overlay {
            position: fixed; inset: 0; z-index: 9; overflow: hidden; pointer-events: none;
        }
        body.photo-layout-active #tree-name-overlay { display: none; }
        
        .node-name {
            position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%);
            width: max-content; max-width: 110px; font-weight: bold; word-wrap: break-word; line-height: 1.2;
            box-sizing: border-box; padding: 3px 5px; background: rgba(0, 0, 0, 0.5); border-radius: 3px;
        }
        #tree-name-overlay.vertical-drawn-labels .node-name {
            max-width: min(175px, 24vw); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        }
        .node-scientific { color: #aaa; font-size: 10px; font-style: italic; line-height: 1.15; }
        .node-glyphs { display: flex; gap: 5px; font-size: 14px; justify-content: center; flex-wrap: wrap; }
        .node-label > .node-glyphs { padding: 3px 5px; background: rgba(0, 0, 0, 0.5); border-radius: 3px; }
        .node-glyphs a, .node-glyphs span { text-decoration: none; cursor: pointer; transition: transform 0.1s; }
        .node-glyphs a:hover, .node-glyphs span:hover { transform: scale(1.2); }
        .internal-node-anchor { display: inline-block; line-height: 0; }
        .internal-node { width: 8px; height: 8px; background: #888; border-radius: 50%; border: 1px solid #fff; }
        .internal-node.named-taxonomy-node { cursor: pointer; pointer-events: auto; }
        .internal-node.named-taxonomy-node::after {
            content: attr(data-taxonomy-name); position: absolute; top: calc(100% + 5px); left: 50%;
            transform: translateX(-50%); width: max-content; max-width: 180px; padding: 2px 4px;
            color: #ddd; background: rgba(0,0,0,0.62); border-radius: 2px;
            font-size: 9px; line-height: 1.2; font-style: italic; text-align: center;
            white-space: normal; opacity: 0; pointer-events: none; transition: opacity 0.12s;
        }
        .internal-node.named-taxonomy-node:hover::after { opacity: 1; }
        .sphere-intro-active .internal-node.named-taxonomy-node:hover::after {
            opacity: var(--sphere-intro-text-opacity, 0);
        }
        .internal-node.dna-node { border: 0; opacity: 0.7; }
        .internal-node.dna-branch-node { width: 3px; height: 3px; background: rgb(210,225,255); }
        .internal-node.dna-pass-node { width: 2.25px; height: 2.25px; background: rgb(210,225,255); }
        .internal-node.metal-node {
            width: 8px; height: 8px; border: 1px solid #dce5ec;
            background: radial-gradient(circle at 30% 24%, #fff 0 9%, #c6d1da 24%, #788b9b 55%, #354452 100%);
            box-shadow: inset -1px -1px 2px rgba(0,0,0,0.5), 0 0 4px rgba(215,232,245,0.75);
        }
        .internal-node.whispy-node {
            width: 11px; height: 10px; border: 1px solid hsla(var(--whispy-hue, 185), 48%, 91%, 0.62);
            border-radius: var(--whispy-r1, 58%) var(--whispy-r2, 42%) var(--whispy-r3, 55%) var(--whispy-r4, 45%) / 48% 57% 43% 52%;
            background:
                radial-gradient(circle at 34% 28%, rgba(255,255,255,0.68) 0 7%, transparent 23%),
                radial-gradient(circle at 54% 60%, hsla(var(--whispy-hue, 185), 52%, 80%, 0.58), hsla(var(--whispy-hue, 185), 38%, 65%, 0.22) 58%, transparent 76%);
            box-shadow:
                inset 1px 1px 2px rgba(255,255,255,0.28),
                inset -2px -2px 3px rgba(70,90,110,0.22),
                0 0 5px hsla(var(--whispy-hue, 185), 70%, 77%, 0.38);
            opacity: 0.84;
        }
        .internal-node.whispy-node::before {
            content: ""; position: absolute; inset: -3px; border-radius: inherit;
            background: hsla(var(--whispy-hue, 185), 62%, 72%, 0.12); filter: blur(3px); z-index: -1;
        }
        .internal-node.named-taxonomy-node { width: 9.6px; height: 9.6px; }
        .internal-node.named-taxonomy-node.dna-branch-node { width: 3.6px; height: 3.6px; }
        .internal-node.named-taxonomy-node.dna-pass-node { width: 2.7px; height: 2.7px; }
        .internal-node.named-taxonomy-node.metal-node { width: 9.6px; height: 9.6px; }
        .internal-node.named-taxonomy-node.whispy-node { width: 13.2px; height: 12px; }

        #clade-detail {
            display: none; position: fixed; z-index: 10000001; width: min(380px, calc(100vw - 24px));
            max-height: min(440px, calc(100vh - 24px)); box-sizing: border-box; overflow: hidden;
            padding: 10px 12px; color: #ddd; background: rgba(7,7,7,0.92);
            border: 1px solid rgba(255,255,255,0.14); border-radius: 5px;
            box-shadow: 0 7px 22px rgba(0,0,0,0.42);
        }
        #clade-detail.visible { display: block; }
        #clade-links { justify-content: center; gap: 8px; margin-bottom: 6px; font-size: 22.4px; line-height: 1; }
        #clade-name { font-size: 14px; line-height: 1.2; font-style: italic; text-align: center; }
        #clade-rank { margin-top: 2px; color: #888; font-size: 9px; text-align: center; text-transform: capitalize; }
        #clade-summary {
            margin-top: 7px; max-height: min(17em, 35vh); overflow-y: auto; color: #ccc;
            font-size: clamp(11px, 1.1vw, 14px); line-height: 1.4; text-align: left; scrollbar-width: thin;
        }

        @keyframes imgPulse { 0% { opacity: 0.4; } 50% { opacity: 1; } 100% { opacity: 0.4; } }
        .img-loading { animation: imgPulse 1s infinite; border: 0 !important; background: transparent !important;}

        .node-img { 
            width: 96px; height: 60px; object-fit: contain; border: 0; border-radius: 10%;
            cursor: pointer; transition: 0.2s; background: transparent;
            animation: imgGrow 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }
        @keyframes imgGrow { from { transform: scale(0); } to { transform: scale(1); } }
        
        .node-img:not(.img-loading):hover { transform: scale(1.05); }
        .sphere-tree .node-img { cursor: grab; }
        .sphere-tree .node-img:active { cursor: grabbing; }

        #image-detail {
            display: none; position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
            width: min(1180px, calc(100vw - 40px)); height: min(86vh, 760px); max-height: calc(100vh - 40px); z-index: 10000000;
            box-sizing: border-box; padding: 14px 14px 28px; background: rgba(5, 5, 5, 0.94);
            grid-template-columns: minmax(320px, 0.72fr) 48px minmax(360px, 1.28fr);
            grid-template-rows: minmax(0, 1fr); grid-template-areas: "copy controls media";
            gap: 14px; overflow: hidden;
        }
        #image-detail.visible { display: grid; }
        #detail-tree-position {
            position: absolute; top: 0; right: 0; z-index: 5;
            display: grid; place-items: center; min-width: 15px; height: 15px;
            box-sizing: border-box; padding: 0 1px; border: 0;
            border-radius: 0; background: #000; color: #fff;
            font: 600 8px/1 "Segoe UI", sans-serif;
        }
        #image-detail.detail-transitioning {
            background: transparent !important; box-shadow: none !important;
        }
        #image-detail.detail-transitioning > * { visibility: hidden; }
        #image-detail > :not(#detail-range-map-overlay) { transition: opacity 0.2s ease; }
        #image-detail.map-opening > :not(#detail-range-map-overlay) { opacity: 0.1; }
        #detail-transition-image {
            position: fixed; z-index: 10000003; margin: 0; padding: 0;
            object-fit: contain; object-position: center; pointer-events: none;
            background: transparent; box-shadow: none;
        }
        #image-detail.fullscreen {
            top: 0; width: 100vw; height: 100vh; max-height: 100vh;
            padding: 16px 16px 30px; background: rgba(3, 3, 3, 0.985);
            grid-template-columns: minmax(340px, 0.72fr) 48px minmax(0, 1.28fr);
            grid-template-rows: minmax(0, 1fr); grid-template-areas: "copy controls media";
        }
        #detail-media {
            grid-area: media; display: grid; grid-template-rows: minmax(0, 1fr);
            min-width: 0; min-height: 0; overflow: hidden;
        }
        #detail-image {
            display: block; width: 100%; height: 100%; min-width: 0; min-height: 120px;
            object-fit: contain; object-position: center; cursor: zoom-out;
        }
        #detail-credit {
            position: absolute; right: 14px; bottom: 8px; max-width: calc(100% - 28px);
            color: #858585; font-size: 9px; line-height: 1.25; text-align: right;
            overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
        }
        #detail-credit a { color: #929292; text-decoration: none; }
        #detail-credit a:hover { color: #bbb; text-decoration: underline; }
        #detail-copy {
            position: relative; grid-area: copy; display: grid;
            grid-template-rows: minmax(0, 1fr) 180px minmax(0, 1fr);
            min-width: 0; min-height: 0; gap: 8px; overflow: hidden; padding-right: 3px;
        }
        #detail-copy-upper, #detail-copy-lower {
            min-width: 0; min-height: 0; overflow-y: auto; scrollbar-width: thin;
        }
        #detail-copy-upper {
            display: flex; flex-direction: column; gap: 10px;
        }
        #detail-info-row {
            display: grid; grid-template-columns: minmax(0, 1fr) 48px; gap: 8px;
            flex: 1 1 auto; min-width: 0; min-height: 0;
        }
        #detail-data-toggles {
            display: grid; grid-template-columns: minmax(0, 1fr);
            align-self: start; min-width: 0;
        }
        #detail-info-toggle {
            display: grid; grid-template-rows: auto 16px; place-items: center;
            width: 44px; min-height: 38px; margin: 0; padding: 3px 2px;
            border: 1px solid rgba(255,255,255,0.15); border-radius: 8px;
            background: rgba(105,150,105,0.16); color: #a9cbaa;
            font: 600 8px/1.05 'Segoe UI', sans-serif; letter-spacing: 0.03em; text-transform: uppercase; opacity: 0.85;
        }
        #detail-info-toggle .detail-toggle-state { font: 600 11px/16px 'Segoe UI Symbol', sans-serif; }
        #detail-info-toggle:hover { background: rgba(105,150,105,0.28); opacity: 1; }
        #detail-info-toggle[aria-checked="false"] {
            background: rgba(145,95,95,0.12); color: #a78484;
        }
        #detail-info-toggle[aria-checked="false"]:hover { background: rgba(145,95,95,0.23); }
        #detail-copy-lower {
            display: flex; flex-direction: column; gap: 8px;
        }
        #detail-names {
            display: flex; align-items: baseline; justify-content: center; flex-wrap: wrap;
            column-gap: 10px; row-gap: 3px; min-width: 0; text-align: center; line-height: 1.2;
        }
        #detail-common { font-size: 24px; font-weight: 600; overflow-wrap: anywhere; }
        #detail-scientific { color: #aaa; font-size: 20px; font-style: italic; overflow-wrap: anywhere; }
        #image-detail #detail-links {
            grid-row: 3; align-self: center; flex-direction: column; flex-wrap: nowrap; justify-content: center;
            gap: 8px; margin: 0; padding: 0; font-size: 22.4px; line-height: 1;
        }
        #detail-controls {
            grid-area: controls; display: grid; grid-template-rows: repeat(3, minmax(0, 1fr));
            align-items: stretch; justify-items: center; min-width: 0; min-height: 0;
        }
        #detail-controls-upper {
            grid-row: 1; align-self: center; display: flex; flex-direction: column;
            align-items: center; justify-content: center; gap: 8px;
        }
        .detail-view-control {
            width: 42px; height: 42px; margin: 0; padding: 0; border: 0; border-radius: 50%;
            background: transparent; color: #ddd; font-size: 17px; line-height: 42px; cursor: pointer;
            opacity: 0.86; transition: opacity 0.15s, transform 0.15s;
        }
        .detail-view-control:hover { opacity: 1; transform: scale(1.12); background: rgba(255,255,255,0.08); }
        #detail-close { font-size: 25.5px; }
        .detail-nav-control { font-size: 29px; font-weight: 300; }
        .detail-view-control:disabled { opacity: 0.2; cursor: default; transform: none; }
        #detail-summary-stack { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
        #detail-summary {
            flex: 1 1 auto;
            min-width: 0; min-height: 2.8em; overflow-y: auto;
            color: #ccc; font-size: clamp(11px, 1.1vw, 14px); line-height: 1.4; text-align: left;
            scrollbar-width: thin;
        }
        #detail-conservation-status {
            flex: 0 0 auto; padding: 4px 0 1px; color: #aaa;
            font-size: 10px; line-height: 1.2; text-align: center; letter-spacing: 0.02em;
        }
        #detail-conservation-status[hidden] { display: none; }
        .detail-summary-source {
            margin-left: 6px; color: #777; font-size: 8px; line-height: 1; text-decoration: none;
            white-space: nowrap;
        }
        .detail-summary-source:hover { color: #aaa; text-decoration: underline; }
        .detail-summary-missing-wiki {
            margin-top: 8px; padding-top: 6px; border-top: 1px solid rgba(255,255,255,0.15);
            color: #aaa; font-size: 0.88em; line-height: 1.35;
        }
        .detail-summary-missing-wiki a { color: #8fc5ff; text-decoration: none; }
        .detail-summary-missing-wiki a:hover { color: #c7e2ff; text-decoration: underline; }
        #detail-summary.summary-overflowing:hover {
            position: absolute; top: var(--summary-top, 0); right: 3px; bottom: 0; left: 0;
            z-index: 6; box-sizing: border-box; padding: 6px 7px; overflow-y: auto;
            background: rgba(3,3,3,0.985); box-shadow: 0 -6px 15px rgba(0,0,0,0.3);
        }
        #detail-context-visuals {
            position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
            align-items: center; gap: 14px; min-width: 0; min-height: 0;
        }
        #detail-conservation-badge {
            position: absolute; top: 0; left: 3px; z-index: 1;
            display: grid; place-items: center; width: 16px; height: 16px;
            box-sizing: border-box; border-radius: 50%; color: #000;
            font: 700 8px/1 'Segoe UI', sans-serif; letter-spacing: -0.04em;
        }
        #detail-conservation-badge[hidden] { display: none; }
        #detail-conservation-badge[data-category="CR"],
        #detail-conservation-badge[data-category="G1"] { background: #ff3333; }
        #detail-conservation-badge[data-category="EN"],
        #detail-conservation-badge[data-category="G2"] { background: #e63366; }
        #detail-conservation-badge[data-category="VU"],
        #detail-conservation-badge[data-category="G3"] { background: #993399; }
        #detail-conservation-badge[data-category="NT"],
        #detail-conservation-badge[data-category="G4"] { background: #33c7b9; }
        #detail-conservation-badge[data-category="LC"],
        #detail-conservation-badge[data-category="G5"] { background: #33ccff; }
        #detail-conservation-badge[data-category="EW"],
        #detail-conservation-badge[data-category="EX"],
        #detail-conservation-badge[data-category="GX"] {
            border: 1px solid #ff3333; background: #000; color: #fff;
        }
        #detail-conservation-badge[data-category="GH"] { background: #663366; color: #fff; }
        #detail-conservation-badge[data-category="DD"] { background: #cccccc; }
        #detail-conservation-badge[data-category="NE"] { background: #f2f2f2; }
        #detail-conservation-callout {
            position: absolute; top: 18px; left: 0; z-index: 1;
            color: #fff; font: 8px/1.1 'Segoe UI', sans-serif;
            white-space: nowrap; text-shadow: 0 1px 2px #000;
        }
        #detail-conservation-callout[hidden] { display: none; }
        #detail-range-map { margin: 0; padding: 7px; text-align: center; }
        #detail-range-map[hidden] { display: none; }
        #detail-range-map-image {
            display: block; width: 100%; max-height: 170px; margin: 0 auto; object-fit: contain;
            opacity: 0; transition: opacity 0.2s ease; cursor: zoom-in;
        }
        #detail-range-map-image.loaded { opacity: 1; }
        #detail-range-map-link { color: #686868; font-size: 7px; line-height: 1; text-decoration: none; }
        #detail-range-map-link:hover { color: #aaa; text-decoration: underline; }
        #detail-mini-tree { min-width: 0; margin: 0; padding: 3px; }
        #detail-mini-tree[hidden] { display: none; }
        #detail-mini-tree-svg {
            display: block; width: 100%; height: 112px; overflow: visible;
        }
        .mini-tree-leaf-hit { cursor: pointer; outline: none; }
        .mini-tree-leaf-hit:focus { stroke: rgba(255,255,255,0.55); stroke-width: 1; }
        .mini-tree-center-hit {
            fill: rgba(96,165,250,0.035); stroke: rgba(147,197,253,0.2); stroke-width: 0.7;
            cursor: zoom-in; pointer-events: all; outline: none;
        }
        .mini-tree-center-hit:hover, .mini-tree-center-hit:focus {
            fill: rgba(96,165,250,0.14); stroke: rgba(147,197,253,0.78); stroke-width: 1.2;
        }
        .tree-return-transition {
            position: fixed; z-index: 10000003; display: block; margin: 0;
            pointer-events: none; opacity: 0.5; overflow: visible; transform-origin: top left; will-change: transform, opacity;
        }
        #detail-taxonomy-links {
            flex: 0 0 auto; display: flex; flex-direction: column; gap: 3px;
            color: #777; font-size: 9px; line-height: 1.25;
        }
        #detail-taxonomy-links[hidden] { display: none; }
        .detail-taxonomy-link-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px; }
        .detail-taxonomy-link-label { color: #686868; min-width: 43px; }
        .detail-taxonomy-link-row a { color: #9a9a9a; text-decoration: none; }
        .detail-taxonomy-link-row a:hover { color: #ccc; text-decoration: underline; }
        .detail-taxonomy-link-separator { color: #505050; }
        #detail-range-map-overlay {
            position: fixed; inset: 0; z-index: 10000002; box-sizing: border-box;
            display: flex; align-items: center; justify-content: center; padding: 30px;
            background: rgba(0, 0, 0, 0.8);
        }
        #detail-range-map-overlay[hidden] { display: none; }
        #detail-range-map-overlay.transitioning { background: transparent !important; }
        #detail-range-map-large {
            display: block; width: 50vw; max-width: calc(100vw - 60px); max-height: calc(100vh - 60px);
            object-fit: contain; cursor: zoom-out;
        }
        .map-zoom-transition {
            position: fixed; z-index: 10000003; display: block; margin: 0; object-fit: contain;
            pointer-events: none; opacity: 0.5; transform-origin: top left; will-change: transform;
        }
        .detail-fact-section {
            flex: 0 0 auto; padding-top: 3px;
        }
        .detail-fact-section[hidden] { display: none; }
        .detail-fact-heading {
            display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
            margin-bottom: 5px; color: #929292; font-size: 9px; line-height: 1.2;
            letter-spacing: 0.08em; text-transform: uppercase;
        }
        .detail-fact-heading a { color: #777; font-size: 8px; letter-spacing: 0; text-decoration: none; text-transform: none; }
        .detail-fact-heading a:hover { color: #bbb; text-decoration: underline; }
        .detail-fact-list { display: flex; flex-direction: column; gap: 4px; }
        .detail-fact {
            display: grid; grid-template-columns: 19px minmax(0, 1fr); gap: 4px;
            color: #bbb; font-size: clamp(9px, 0.88vw, 11px); line-height: 1.28;
        }
        .detail-fact-icon { color: #aaa; text-align: center; filter: saturate(0.72); }
        .detail-fact-label { color: #888; }
        .detail-fact-value { color: #c8c8c8; }

        #wiki-modal { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 400px; max-width: 90vw; background: #1e1e1e; border: 1px solid #555; border-radius: 8px; padding: 20px; z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,0.8); color: white; }
        #wiki-modal h3 { margin-top: 0; }
        #wiki-close { float: right; cursor: pointer; color: #aaa; font-weight: bold; }
        #wiki-close:hover { color: white; }
        #wiki-content { font-size: 14px; line-height: 1.5; color: #ccc; max-height: 60vh; overflow-y: auto; }

        #loading-gallery {
            display: none; position: fixed; top: 20px; right: 20px; bottom: 20px; left: 345px;
            z-index: 20; padding: 8px; background: transparent;
            border: 0; border-radius: 0; box-shadow: none;
            flex-direction: column; gap: 14px;
        }
        #loading-gallery.visible { display: flex; }
        #loading-gallery.dense-results { top: 62px; right: 20px; left: 20px; }
        #gallery-status { margin: 0; font-size: 17px; color: #e5eefb; }
        #gallery-subtitle { margin-top: -8px; font-size: 11px; color: #93a4b8; }
        #gallery-grid {
            flex: 1; min-height: 0; overflow: hidden; display: grid; gap: 8px;
            grid-template-columns: repeat(5, minmax(0, 1fr));
            grid-template-rows: repeat(4, minmax(0, 1fr));
            background: #080b0f;
        }
        #gallery-grid.dense-results {
            width: 100%; margin-inline: auto; gap: 4px;
            grid-template-columns: repeat(15, minmax(0, 1fr));
            grid-template-rows: repeat(var(--dense-rows, 3), minmax(0, 1fr));
        }
        #gallery-grid.dense-results .gallery-card:nth-child(n) {
            display: block; grid-column: auto; grid-row: auto;
        }
        #gallery-grid.dense-results .gallery-card-label { padding: 12px 3px 3px; }
        #gallery-grid.dense-results .gallery-card-name { font-size: 9px; }
        #gallery-grid.dense-results .gallery-card-scientific { display: none; }
        .gallery-card {
            position: relative; min-width: 0; min-height: 0; overflow: hidden;
            background: #10151b; border: 0; border-radius: 5px; padding: 0;
            opacity: 0; animation: galleryFadeIn 0.3s ease-out forwards; cursor: zoom-in;
        }
        .gallery-card:focus-visible { outline: 3px solid #60a5fa; outline-offset: -3px; }
        @keyframes galleryFadeIn { from { opacity: 0; } to { opacity: 1; } }
        .gallery-card-label {
            position: absolute; right: 0; bottom: 0; left: 0; z-index: 1;
            padding: 18px 6px 5px; text-align: center;
            background: linear-gradient(transparent, rgba(3, 6, 9, 0.88));
            pointer-events: none;
        }
        .gallery-card-name {
            overflow: hidden; color: white; font-size: clamp(9px, 0.82vw, 13px); font-weight: 600;
            line-height: 1.15; text-overflow: ellipsis; white-space: nowrap;
        }
        .gallery-card-scientific {
            overflow: hidden; margin-top: 2px; color: #c5ced8; font-size: clamp(8px, 0.65vw, 10px);
            font-style: italic; line-height: 1.1; text-overflow: ellipsis; white-space: nowrap;
        }
        .gallery-card img { width: 100%; height: 100%; object-fit: cover; background: #0b0f14; }
        .gallery-card-main { grid-column: 2 / 5; grid-row: 2 / 4; border-radius: 7px; }
        .gallery-card-main .gallery-card-label { padding: 42px 12px 10px; text-align: left; }
        .gallery-card-main .gallery-card-name { font-size: clamp(17px, 1.65vw, 27px); }
        .gallery-card-main .gallery-card-scientific { font-size: clamp(11px, 0.9vw, 15px); }

        /* Five by four perimeter, filled clockwise; later photos reuse its slots. */
        .gallery-card:nth-child(2)  { grid-column: 1; grid-row: 1; }
        .gallery-card:nth-child(3)  { grid-column: 2; grid-row: 1; }
        .gallery-card:nth-child(4)  { grid-column: 3; grid-row: 1; }
        .gallery-card:nth-child(5)  { grid-column: 4; grid-row: 1; }
        .gallery-card:nth-child(6)  { grid-column: 5; grid-row: 1; }
        .gallery-card:nth-child(7)  { grid-column: 5; grid-row: 2; }
        .gallery-card:nth-child(8)  { grid-column: 5; grid-row: 3; }
        .gallery-card:nth-child(9)  { grid-column: 5; grid-row: 4; }
        .gallery-card:nth-child(10) { grid-column: 4; grid-row: 4; }
        .gallery-card:nth-child(11) { grid-column: 3; grid-row: 4; }
        .gallery-card:nth-child(12) { grid-column: 2; grid-row: 4; }
        .gallery-card:nth-child(13) { grid-column: 1; grid-row: 4; }
        .gallery-card:nth-child(14) { grid-column: 1; grid-row: 3; }
        .gallery-card:nth-child(15) { grid-column: 1; grid-row: 2; }
        .gallery-card:nth-child(n+16) { display: none; }

        #image-sources {
            display: none; position: fixed; right: 14px; bottom: 10px; z-index: 12;
            color: #aaa; font-size: 12px; background: rgba(18,18,18,0.72); padding: 4px 7px; border-radius: 4px;
        }

        #tree-memory-panel {
            position: fixed; inset: 52px 0 0; z-index: 13; box-sizing: border-box;
            overflow: auto; padding: clamp(12px, 2vw, 28px);
            background: rgba(3, 7, 12, 0.97); scrollbar-width: thin;
        }
        #tree-memory-panel[hidden] { display: none; }
        #tree-history-offer {
            width: min(440px, calc(100vw - 32px)); box-sizing: border-box; padding: 23px;
            border: 1px solid #8797a7; border-radius: 12px; color: #fff; background: #111a24;
            box-shadow: 0 18px 55px rgba(0,0,0,0.55); font: 16px/1.45 system-ui, sans-serif;
        }
        #tree-history-offer::backdrop { background: rgba(0,0,0,0.55); }
        #tree-history-offer p { margin: 0 0 20px; }
        .tree-history-offer-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
        .tree-history-offer-actions button {
            min-height: 36px; padding: 6px 14px; border: 1px solid #8290a0; border-radius: 6px;
            color: inherit; background: #253445; font: inherit; cursor: pointer;
        }
        #tree-history-offer-accept { border-color: #85baff; background: #235d9d; }
        html[data-theme="day"] #tree-history-offer { color: #111; background: #fff; }
        html[data-theme="day"] .tree-history-offer-actions button { color: #111; background: #edf2f7; }
        html[data-theme="day"] #tree-history-offer-accept { color: #fff; background: #005fcc; }
        #drawn-path-overlay {
            position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 12;
            pointer-events: none; display: none;
        }
        #drawn-path-overlay.active { display: block; }
        #drawn-path-line {
            fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round;
            stroke-linejoin: round; stroke-dasharray: 7 5; opacity: 0.9;
        }
        #drawn-path-overlay.symbols #drawn-path-line { display: none; }
        #drawn-path-symbols { display: none; }
        #drawn-path-overlay.symbols #drawn-path-symbols { display: block; }
        .drawn-path-symbol {
            font: 22px/1 'Segoe UI Emoji', 'Apple Color Emoji', sans-serif;
            text-anchor: middle; dominant-baseline: central;
            transform-box: fill-box; transform-origin: center;
            animation: drawn-symbol-drift var(--drift-duration, 1.2s) ease-in-out infinite;
            animation-delay: var(--drift-delay, 0s);
            paint-order: stroke; stroke: rgba(0,0,0,0.55); stroke-width: 1px;
        }
        @keyframes drawn-symbol-drift {
            0%, 100% { transform: translate(0, 0) rotate(-8deg) scale(0.9); opacity: 0.8; }
            50% { transform: translate(var(--drift-x), var(--drift-y)) rotate(var(--drift-spin)) scale(1.12); opacity: 1; }
        }
        @media (prefers-reduced-motion: reduce) {
            .drawn-path-symbol { animation: none; }
        }
        #tree-memory-grid {
            display: grid; grid-template-columns: repeat(var(--memory-columns, 3), minmax(0, 1fr));
            gap: clamp(8px, 1vw, 16px); width: 100%; min-height: 100%; align-content: center;
        }
        .tree-memory-card {
            display: flex; flex-direction: column; width: 100%; max-width: 620px;
            min-width: 0; justify-self: center; margin: 0; padding: 7px; box-sizing: border-box;
            border: 1px solid rgba(255,255,255,0.2); border-radius: 8px;
            background: #0c1218; color: #fff; cursor: pointer; text-align: left;
        }
        .tree-memory-card:hover, .tree-memory-card:focus-visible {
            border-color: #8dc2ff; background: #162433; outline: none;
        }
        .tree-memory-preview { display: block; width: 100%; aspect-ratio: 13 / 7.5; background: #030609; border-radius: 5px; overflow: hidden; }
        .tree-memory-preview svg { display: block; width: 100%; height: 100%; }
        .tree-memory-label { margin-top: 7px; font-size: clamp(12px, 0.95vw, 16px); font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
        .tree-memory-time { margin-top: 2px; color: #aebac8; font-size: clamp(11px, 0.8vw, 13px); line-height: 1.2; }
        @media (max-width: 600px) {
            #tree-memory-grid { grid-template-columns: repeat(min(2, var(--memory-columns, 2)), minmax(0, 1fr)); }
        }

        #photo-layout-overlay {
            position: fixed; inset: 52px 0 0; z-index: 5; box-sizing: border-box;
            overflow: auto; padding: 10px; background: rgba(2,5,8,0.97); scrollbar-width: thin;
        }
        #photo-layout-overlay[hidden] { display: none; }
        #photo-layout-content { width: 100%; min-width: 0; min-height: 100%; box-sizing: border-box; }
        .photo-layout-card, .photo-layout-tree-slot {
            position: relative; min-width: 0; min-height: 0; margin: 0; padding: 0;
            overflow: hidden; border: 1px solid rgba(255,255,255,0.14); border-radius: 7px;
            background: #0a0f14; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
        }
        .photo-layout-card { cursor: zoom-in; }
        .photo-layout-card:focus-visible { outline: 3px solid #60a5fa; outline-offset: -3px; }
        .photo-layout-card img { display: block; width: 100%; height: 100%; object-fit: cover; }
        .photo-layout-card-label, .photo-layout-tree-label {
            position: absolute; right: 0; bottom: 0; left: 0; z-index: 1;
            box-sizing: border-box; overflow: hidden; padding: 20px 6px 5px;
            color: #fff; background: linear-gradient(transparent, rgba(0,0,0,0.88));
            font-size: clamp(9px, 0.8vw, 12px); font-weight: 600; line-height: 1.1;
            text-align: center; text-overflow: ellipsis; white-space: nowrap; pointer-events: none;
        }
        .photo-layout-tree-slot { isolation: isolate; background: #000; cursor: pointer; }
        .photo-layout-tree-slot:focus-visible { outline: 3px solid #60a5fa; outline-offset: -3px; }
        .photo-layout-tree-label { z-index: 2; color: #b9c5d3; }

        #photo-layout-content.layout-uniform {
            display: grid; grid-template-columns: repeat(var(--photo-columns), minmax(110px, 1fr));
            grid-auto-rows: var(--photo-row-size); grid-auto-flow: row dense; gap: 8px;
        }
        .layout-uniform .photo-layout-tree-slot {
            grid-column: var(--tree-column) / span var(--tree-span);
            grid-row: var(--tree-row) / span var(--tree-span);
        }

        #photo-layout-content.layout-justified {
            display: flex; flex-direction: column; gap: 8px;
        }
        .layout-justified .photo-layout-row { display: flex; width: 100%; gap: 8px; flex: none; }
        .layout-justified .photo-layout-card,
        .layout-justified .photo-layout-tree-slot {
            flex: none; height: 100%; box-sizing: border-box;
        }

        #photo-layout-content.layout-mosaic {
            display: grid; grid-template-columns: repeat(var(--photo-columns), minmax(82px, 1fr));
            grid-auto-rows: var(--mosaic-row-height); grid-auto-flow: dense; gap: 8px;
        }
        .layout-mosaic .photo-layout-card[data-shape="landscape"] { grid-column: span 2; }
        .layout-mosaic .photo-layout-card[data-shape="portrait"] { grid-row: span 2; }
        .layout-mosaic .photo-layout-card[data-shape="feature"] { grid-column: span 2; grid-row: span 2; }
        .layout-mosaic .photo-layout-tree-slot {
            grid-column: var(--tree-column) / span 2; grid-row: var(--tree-row) / span 2;
        }

        body.photo-layout-active #canvas-container {
            position: fixed; z-index: 7; pointer-events: none; transform-origin: top left; transition: transform 0.28s cubic-bezier(0.2,0.75,0.25,1);
        }
        body.photo-layout-active #canvas-container * { pointer-events: none !important; }
        body.photo-layout-active #ui-panel,
        body.photo-layout-active #status-panel,
        body.photo-layout-active #image-sources { display: none !important; }

        /* High-contrast night and daytime palettes. */
        html[data-theme="night"] #top-generator-bar { background: rgba(0,0,0,0.88); }
        html[data-theme="night"] #language-button,
        html[data-theme="night"] #settings-button,
        html[data-theme="night"] #theme-toggle,
        html[data-theme="night"] #sfx-toggle,
        html[data-theme="night"] #tree-memory-button,
        html[data-theme="night"] .photo-layout-button { background: #000; border: 1px solid #fff; }
        html[data-theme="night"] .photo-layout-button.active { background: #2563eb; color: #fff; }
        html[data-theme="night"] input[type="text"],
        html[data-theme="night"] select,
        html[data-theme="night"] .slider-group input[type="number"],
        html[data-theme="night"] #dataset-select,
        html[data-theme="night"] #search-dropdown { background: #000; border-color: #fff; color: #fff; }

        html[data-theme="day"] body { background: #fff; color: #111; }
        html[data-theme="day"] #top-generator-bar { background: rgba(255,255,255,0.92); }
        html[data-theme="day"] .panel {
            background: rgba(255,255,255,0.94); border-color: #111; box-shadow: 0 4px 10px rgba(0,0,0,0.18);
        }
        html[data-theme="day"] #language-button,
        html[data-theme="day"] #settings-button,
        html[data-theme="day"] #theme-toggle,
        html[data-theme="day"] #sfx-toggle,
        html[data-theme="day"] #tree-memory-button,
        html[data-theme="day"] .photo-layout-button {
            background: #fff; border: 1px solid #111; color: #111;
        }
        html[data-theme="day"] #language-button:hover,
        html[data-theme="day"] #settings-button:hover,
        html[data-theme="day"] #settings-button[aria-expanded="true"],
        html[data-theme="day"] #language-button[aria-expanded="true"],
        html[data-theme="day"] #theme-toggle:hover,
        html[data-theme="day"] #sfx-toggle:hover,
        html[data-theme="day"] .photo-layout-button:not(:disabled):hover { background: #e5e7eb; }
        html[data-theme="day"] .photo-layout-button.active { background: #005fcc; color: #fff; }
        html[data-theme="day"] #settings-panel { color: #111; background: #fff; border-color: #111; }
        html[data-theme="day"] .settings-control-row select,
        html[data-theme="day"] .settings-control-row button { color: #111; background: #fff; }
        html[data-theme="day"] #settings-video-language { color: #111; background: #fff; }
        html[data-theme="day"] #settings-close:hover { background: rgba(0,0,0,0.09); }
        html[data-theme="day"] #settings-language-options { border-top-color: #bbb; }
        html[data-theme="day"] #photo-layout-overlay { background: rgba(248,250,252,0.98); }
        html[data-theme="day"] #tree-memory-panel { background: rgba(248,250,252,0.98); }
        html[data-theme="day"] .tree-memory-card { background: #fff; border-color: #9ca3af; color: #111; }
        html[data-theme="day"] .tree-memory-card:hover,
        html[data-theme="day"] .tree-memory-card:focus-visible { background: #eaf3ff; border-color: #005fcc; }
        html[data-theme="day"] .tree-memory-time { color: #475569; }
        html[data-theme="day"] .detail-summary-missing-wiki { border-top-color: rgba(0,0,0,0.2); color: #333; }
        html[data-theme="day"] .detail-summary-missing-wiki a { color: #004f9e; }
        html[data-theme="day"] .photo-layout-card,
        html[data-theme="day"] .photo-layout-tree-slot { border-color: rgba(0,0,0,0.24); background: #fff; }
        html[data-theme="day"] #language-menu {
            background: rgba(255,255,255,0.98); border-color: #111; box-shadow: 0 7px 20px rgba(0,0,0,0.2);
        }
        html[data-theme="day"] #random-group-menu { background: rgba(255,255,255,0.98); border-color: #111; }
        html[data-theme="day"] #random-group-menu button { color: #111; }
        html[data-theme="day"] #random-group-menu button:hover,
        html[data-theme="day"] #random-group-menu button[aria-selected="true"] { background: #dbeafe; }
        html[data-theme="day"] .random-group-divider { background: rgba(0,0,0,0.2); }
        html[data-theme="day"] #language-menu button { color: #111; }
        html[data-theme="day"] #language-menu button:hover,
        html[data-theme="day"] #language-menu button[aria-selected="true"] { background: #dbeafe; color: #000; }
        html[data-theme="day"] label,
        html[data-theme="day"] .picker-row,
        html[data-theme="day"] #status-panel,
        html[data-theme="day"] .dropdown-msg,
        html[data-theme="day"] .sci-name { color: #222; }
        html[data-theme="day"] input[type="text"],
        html[data-theme="day"] select,
        html[data-theme="day"] .slider-group input[type="number"],
        html[data-theme="day"] #dataset-select {
            background: #fff; border-color: #111; color: #111;
        }
        html[data-theme="day"] #search-dropdown { background: #fff; border-color: #111; color: #111; }
        html[data-theme="day"] .dropdown-item { border-color: #c7c7c7; }
        html[data-theme="day"] .dropdown-item:hover,
        html[data-theme="day"] .dropdown-item.active { background: #005fcc; color: #fff; }
        html[data-theme="day"] .dropdown-item:hover .sci-name,
        html[data-theme="day"] .dropdown-item.active .sci-name { color: #fff; }
        html[data-theme="day"] #branch-style-picker .style-button,
        html[data-theme="day"] #tree-shape-picker .shape-button { color: #111; }
        html[data-theme="day"] #branch-style-picker .style-button.active,
        html[data-theme="day"] #tree-shape-picker .shape-button.active { background: #005fcc; color: #fff; }
        html[data-theme="day"] .status-good { color: #08752d; }
        html[data-theme="day"] .status-bad { color: #b00020; }
        html[data-theme="day"] .status-warn { color: #7a5600; }

        html[data-theme="day"] .node-label { color: #000; }
        html[data-theme="day"] .node-name,
        html[data-theme="day"] .node-label > .node-glyphs { background: rgba(255,255,255,0.86); }
        html[data-theme="day"] .node-scientific { color: #111; }
        html[data-theme="day"] .internal-node { background: #555; border-color: #000; }
        html[data-theme="day"] .internal-node.metal-node {
            border-color: #263747;
            background: radial-gradient(circle at 30% 24%, #fff 0 9%, #b9c6d0 23%, #718493 52%, #263747 100%);
            box-shadow: inset -1px -1px 2px rgba(0,0,0,0.45), 0 0 2px rgba(20,39,55,0.65);
        }
        html[data-theme="day"] .internal-node.named-taxonomy-node::after {
            color: #000; background: rgba(255,255,255,0.94); border: 1px solid #111;
        }

        html[data-theme="day"] #map-search-dialog,
        html[data-theme="day"] #clade-detail,
        html[data-theme="day"] #image-detail,
        html[data-theme="day"] #wiki-modal {
            background: rgba(255,255,255,0.98); border-color: #111; color: #111;
            box-shadow: 0 12px 35px rgba(0,0,0,0.24);
        }
        html[data-theme="day"] #map-search-close,
        html[data-theme="day"] .detail-view-control,
        html[data-theme="day"] #wiki-close { color: #111; }
        html[data-theme="day"] #map-search-close:hover,
        html[data-theme="day"] .detail-view-control:hover { background: rgba(0,0,0,0.08); }
        html[data-theme="day"] #map-radius-control,
        html[data-theme="day"] #map-search-progress,
        html[data-theme="day"] #map-search-status,
        html[data-theme="day"] #map-species-log,
        html[data-theme="day"] #map-attribution,
        html[data-theme="day"] #clade-rank,
        html[data-theme="day"] #clade-summary,
        html[data-theme="day"] #detail-credit,
        html[data-theme="day"] #detail-scientific,
        html[data-theme="day"] #detail-summary,
        html[data-theme="day"] .detail-taxonomy-link-row,
        html[data-theme="day"] .detail-fact-heading,
        html[data-theme="day"] .detail-fact,
        html[data-theme="day"] .detail-fact-icon,
        html[data-theme="day"] .detail-fact-label,
        html[data-theme="day"] .detail-fact-value,
        html[data-theme="day"] #wiki-content { color: #222; }
        html[data-theme="day"] #map-species-log { background: rgba(0,0,0,0.06); }
        html[data-theme="day"] .map-step-label,
        html[data-theme="day"] .map-progress-meter,
        html[data-theme="day"] #map-search-duration { color: #222; }
        html[data-theme="day"] .map-photo-slot { background: #e1e7ec; }
        html[data-theme="day"] .leaflet-container { background: #e5edf4; }
        html[data-theme="day"] #detail-credit a,
        html[data-theme="day"] .detail-summary-source,
        html[data-theme="day"] #detail-range-map-link,
        html[data-theme="day"] .detail-taxonomy-link-row a,
        html[data-theme="day"] .detail-fact-heading a { color: #004c99; }
        html[data-theme="day"] #detail-summary.summary-overflowing:hover { background: rgba(255,255,255,0.98); }
        html[data-theme="day"] #detail-range-map-overlay { background: rgba(255,255,255,0.9); }
        html[data-background-tone="light"] .internal-node.whispy-node {
            border-color: hsla(var(--whispy-hue, 185), 65%, 22%, 0.8);
            background: radial-gradient(circle at 42% 38%, hsla(var(--whispy-hue, 185), 58%, 42%, 0.8), hsla(var(--whispy-hue, 185), 54%, 22%, 0.72) 62%, transparent 78%);
            box-shadow: 0 0 3px hsla(var(--whispy-hue, 185), 62%, 20%, 0.35);
        }
        html[data-background-tone="light"] .internal-node.whispy-node::before { background: hsla(var(--whispy-hue, 185), 62%, 26%, 0.15); }

        html[data-sfx="off"] *,
        html[data-sfx="off"] *::before,
        html[data-sfx="off"] *::after { transition-duration: 0s !important; scroll-behavior: auto !important; }
        html[data-sfx="off"] .gallery-card,
        html[data-sfx="off"] .node-label,
        html[data-sfx="off"] .node-img,
        html[data-sfx="off"] .img-loading,
        html[data-sfx="off"] .map-progress-blocks { animation: none !important; }
        html[data-sfx="off"] .gallery-card,
        html[data-sfx="off"] .node-label { opacity: 1; }
        html[data-theme="day"] #gallery-status { color: #111; }
        html[data-theme="day"] #gallery-subtitle { color: #333; }
        html[data-theme="day"] #gallery-grid { background: #fff; }
        html[data-theme="day"] .gallery-card { background: #e5e7eb; }
        html[data-theme="day"] .gallery-card img { background: #eef0f2; }
        html[data-theme="day"] #image-sources { color: #111; background: rgba(255,255,255,0.9); border: 1px solid #111; }

        @media (max-width: 1100px) {
            #gallery-grid {
                grid-template-columns: repeat(4, minmax(0, 1fr));
                grid-template-rows: repeat(4, minmax(0, 1fr));
            }
            .gallery-card-main { grid-column: 2 / 4; grid-row: 2 / 4; }
            .gallery-card:nth-child(2)  { grid-column: 1; grid-row: 1; }
            .gallery-card:nth-child(3)  { grid-column: 2; grid-row: 1; }
            .gallery-card:nth-child(4)  { grid-column: 3; grid-row: 1; }
            .gallery-card:nth-child(5)  { grid-column: 4; grid-row: 1; }
            .gallery-card:nth-child(6)  { grid-column: 4; grid-row: 2; }
            .gallery-card:nth-child(7)  { grid-column: 4; grid-row: 3; }
            .gallery-card:nth-child(8)  { grid-column: 4; grid-row: 4; }
            .gallery-card:nth-child(9)  { grid-column: 3; grid-row: 4; }
            .gallery-card:nth-child(10) { grid-column: 2; grid-row: 4; }
            .gallery-card:nth-child(11) { grid-column: 1; grid-row: 4; }
            .gallery-card:nth-child(12) { grid-column: 1; grid-row: 3; }
            .gallery-card:nth-child(13) { grid-column: 1; grid-row: 2; }
            .gallery-card:nth-child(n+14) { display: none; }
        }

        @media (max-width: 800px) {
            #loading-gallery { left: 15px; top: 455px; }
            #image-detail {
                width: calc(100vw - 20px); height: calc(100vh - 20px); top: 10px; max-height: calc(100vh - 20px); padding: 8px;
                grid-template-columns: minmax(190px, 0.72fr) 42px minmax(0, 1.28fr);
                grid-template-rows: minmax(0, 1fr); grid-template-areas: "copy controls media";
            }
            #image-detail.fullscreen {
                top: 0; width: 100vw; height: 100vh; max-height: 100vh;
                grid-template-columns: minmax(190px, 0.72fr) 42px minmax(0, 1.28fr);
                grid-template-rows: minmax(0, 1fr); grid-template-areas: "copy controls media";
            }
            #detail-controls-upper { gap: 10px; }
            .detail-view-control { width: 38px; height: 38px; line-height: 38px; }
        }
