:root{--text:#25313d;--page:#f3f5f8;--surface:#ffffff;--sidebar:#fafbfc;--divider:#e0e5ec;--border:#8794a5;--muted:#536174;--accent:#294fb9;--selected:#eaf0ff;--hover:#e3e9f2;--focus:#245ddd;--warning:#8c4500;color-scheme:light}
:root[data-theme=studio]{--text:#edf0f5;--page:#15191f;--surface:#1d232c;--sidebar:#181e26;--divider:#556173;--border:#748196;--muted:#b2becf;--accent:#a5c2ff;--selected:#2b3c56;--hover:#303b4b;--focus:#a9cbff;--warning:#ffd29b;color-scheme:dark}
:root[data-theme=fieldnotes]{--text:#263d32;--page:#e9eee4;--surface:#f6f8ef;--sidebar:#edf2e7;--divider:#879d89;--border:#7e917f;--muted:#4d6654;--accent:#285b3a;--selected:#dbe8d4;--hover:#e0ead9;--focus:#286441;--warning:#7b4300;color-scheme:light}
*{box-sizing:border-box} :root{font:15px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif;color:var(--text);background:var(--page)}body{margin:0;min-width:280px}button,a,input{font:inherit}button{color:inherit;cursor:pointer}button:disabled{cursor:default}button:focus-visible,a:focus-visible,[tabindex]:focus-visible,input:focus-visible{outline:3px solid var(--focus);outline-offset:3px}button{border:1px solid var(--border);border-radius:7px;background:var(--surface);padding:8px 12px}a{color:inherit}.appbar{height:76px;display:flex;align-items:center;gap:70px;background:var(--surface);border-bottom:1px solid var(--border);padding:0 30px}.brand{font-size:22px;letter-spacing:-.8px;font-weight:650;text-decoration:none}.brand span{color:var(--accent)}nav{display:flex;height:100%;gap:26px}nav button{border:0;border-radius:0;border-bottom:3px solid transparent;background:transparent;padding:0 4px}nav [aria-selected=true]{border-color:var(--accent);color:var(--accent);font-weight:650}#menu{display:none}#workspace{--side:260px;display:grid;grid-template-columns:var(--side) 10px minmax(0,1fr);min-height:600px;height:calc(100dvh - 150px);background:var(--surface)}#side{min-width:0;background:var(--sidebar);overflow:auto;padding:26px 16px}#divider{background:var(--divider);cursor:col-resize;touch-action:none;border-inline:3px solid var(--surface)}#divider:hover,#divider:focus{background:var(--accent)}#catalogue{min-width:0}.nav-label,.eyebrow{text-transform:uppercase;letter-spacing:.13em;font-size:11px;color:var(--muted);font-weight:650}.nav-label{padding-left:12px;margin:0 0 16px}.group-toggle{display:block;width:100%;text-align:left;background:transparent;border:0;padding:13px 12px;font-weight:600}.group-toggle:before{content:'▸';display:inline-block;width:20px;color:var(--muted)}.group-toggle[aria-expanded=true]:before{content:'▾'}.items{margin:0 0 8px 20px}.items[hidden]{display:none}.item{display:block;width:100%;text-align:left;border:0;background:transparent;font-size:14px;padding:9px 12px}.item[aria-current=true]{color:var(--accent);background:var(--selected);font-weight:600}.item:hover{background:var(--hover)}.hint{color:var(--muted);font-size:12px;margin:18px 12px;line-height:1.65}.items .hint{margin:3px 12px 6px}.tools{display:flex;justify-content:flex-end;margin-bottom:16px}fieldset{border:1px solid var(--border);border-radius:8px;margin:0 0 18px;padding:10px}fieldset label{display:flex;align-items:center;gap:8px;padding:5px}input{accent-color:var(--accent)}.table-scroll{overflow:auto;max-width:100%}table{border-collapse:collapse;width:100%;font-size:13px;white-space:nowrap}th,td{text-align:left;padding:10px 8px;border-bottom:1px solid var(--border)}th button{background:transparent;border:0;padding:4px 0;font-size:11px;font-weight:600}td button{padding:3px 8px;border:0;background:transparent;font-weight:700;font-size:17px;color:var(--text)}.selected{background:var(--selected)}.valence,td strong{font-weight:750;color:var(--accent)}#viewer{min-width:0;display:flex;flex-direction:column;padding:40px 44px 24px}#viewer header{flex:none}.eyebrow{margin:0 0 8px}h1{font-size:34px;font-weight:550;letter-spacing:-1px;margin:0 0 8px}.formula{font-size:18px;color:var(--muted);margin:0}#viewSurface{flex:1;display:flex;align-items:center;justify-content:center;flex-direction:column;min-height:220px;gap:20px}#viewSurface img{object-fit:contain;max-width:100%;max-height:55vh}.empty{max-width:390px;text-align:center;border:1px dashed var(--border);padding:32px;border-radius:14px;color:var(--muted)}.empty h2{font-size:18px;font-weight:500;margin:0 0 8px;color:var(--text)}.empty p{font-size:13px;margin:0}.element-badge{border:1px solid var(--border);border-radius:18px;font-size:70px;font-weight:500;width:170px;height:170px;display:grid;place-items:center;background:var(--selected);color:var(--accent)}.caption{font-size:12px;color:var(--muted);text-align:center}footer{display:flex;gap:18px;align-items:center;flex-wrap:wrap;padding:14px 24px;color:var(--muted);font-size:11px}footer button{font-size:11px;padding:4px 8px}footer small{margin-left:auto;font-size:10px}#storageStatus{font-size:12px;color:var(--warning);margin:0 24px}#storageStatus:empty{display:none}dialog{color:inherit;background:var(--surface);border:1px solid var(--border);border-radius:12px;max-width:540px;padding:26px;box-shadow:0 20px 80px #18253826}dialog::backdrop{background:#15233766}#aboutDialog p{line-height:1.8;font-size:14px}#drawer{margin:0;width:min(92vw,620px);height:100dvh;max-height:100dvh;max-width:100vw;border-radius:0 12px 12px 0;padding:20px;overflow:auto}#drawer header{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:24px}#drawer header strong{font-size:15px}#closeDrawer{font-size:12px}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}@media(max-width:1000px){.appbar{gap:35px}#viewer{padding:30px 24px}}@media(max-width:760px){.appbar{height:65px;padding:0 16px;gap:14px}.brand{font-size:17px}.brand span{display:none}nav{gap:13px;margin-left:auto}nav button{font-size:13px}#menu{display:block;font-size:12px;padding:7px 9px}#workspace{display:block;height:calc(100dvh - 170px);min-height:420px}#side,#divider{display:none}#viewer{height:100%;padding:27px 22px 20px}h1{font-size:28px}#viewSurface{min-height:220px}.empty{padding:24px;max-width:330px}footer{padding:12px 16px;gap:8px 14px}footer small{flex-basis:100%;margin:0}#drawer .table-scroll{max-width:100%}}@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important}}

button:hover{background:var(--hover)}nav button:hover{background:var(--hover)}.item[aria-current=true]:hover{background:var(--selected)}
#settings{margin-left:auto;width:40px;height:40px;padding:0;flex:none;font-size:23px;line-height:1;display:grid;place-items:center}
#settingsDialog{width:min(440px,calc(100vw - 24px));max-height:calc(100dvh - 24px);overflow:auto}
#settingsDialog header{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:20px}
#settingsDialog #rotationSettings{margin-top:20px}#rotationSettings label{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin:12px 0}#rotationSettings input{width:96px;min-height:44px;font:inherit;color:var(--text);background:var(--surface);border:1px solid var(--border);border-radius:7px;padding:8px}#rotationSettings .hint{font-size:12px;line-height:1.5}#settingsTitle{font-size:22px;margin:0}#settingsDialog fieldset{margin:0}#themeChoices label{min-height:44px;gap:12px;cursor:pointer}#themeChoices input{width:18px;height:18px}
#viewSurface img{background:#fff;border-radius:10px;padding:12px;width:min(100%,650px);height:auto;aspect-ratio:1;min-height:0}#viewSurface .caption{margin:0;max-width:100%}
.caption a{text-underline-offset:3px}dialog:focus-visible{outline:3px solid var(--focus)}
@media(max-width:760px){.appbar{gap:10px}nav{gap:10px}#settings{width:36px;height:36px;margin-left:0}.brand{font-size:16px}#viewSurface img{max-height:45dvh;width:auto;max-width:100%}}
@media(max-width:360px){.appbar{padding:0 6px;gap:5px}.brand{font-size:14px}nav{gap:7px}nav button{font-size:12px}#menu{font-size:11px;padding:7px}#settings{width:32px;height:36px}}

select{font:inherit;color:var(--text);background:var(--surface);border:1px solid var(--border);border-radius:7px;padding:8px;max-width:100%}select:focus-visible{outline:3px solid var(--focus);outline-offset:3px}.language-choice{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-top:20px;flex-wrap:wrap}#settingsDialog select{min-height:44px}#menu{white-space:nowrap}@media(max-width:360px){.appbar{height:auto;min-height:65px;flex-wrap:wrap;padding:8px;gap:8px}.appbar nav{height:42px;margin-left:0;flex:1}.appbar .brand{flex-basis:100%;font-size:17px}#menu{margin-left:auto}#settings{margin-left:0}#workspace{height:calc(100dvh - 205px)}}

#moleculeInfo{margin-top:18px;max-width:760px;font-size:13px;line-height:1.65}#moleculeInfo[hidden]{display:none}.badges{display:flex;gap:6px;flex-wrap:wrap}.badge{border:1px solid var(--border);border-radius:20px;padding:3px 9px;font-size:11px;line-height:1.5;background:var(--selected);color:var(--text)}.molecule-note{margin:10px 0 7px}#factDetails{font-size:12px;color:var(--muted)}#factDetails summary{cursor:pointer;width:fit-content;padding:4px 0;text-decoration:underline;text-underline-offset:3px}summary:focus-visible{outline:3px solid var(--focus);outline-offset:3px}#factDetails p{margin:10px 0}#factDetails h3{font-size:12px;margin:14px 0 6px}#factDetails ul{padding-left:20px;margin:6px 0 14px}#factDetails li{margin:4px 0;overflow-wrap:anywhere}#viewer{overflow-y:auto}#viewSurface{flex-shrink:0;padding-top:16px}#viewSurface img{max-height:46dvh}#viewSurface .caption{padding-bottom:8px}@media(max-width:760px){#moleculeInfo{font-size:12px;margin-top:14px}#viewer{height:100%;overflow-y:auto}#viewSurface img{max-height:37dvh}.badge{font-size:10px}}

/* Group-scoped molecule tables: horizontal overflow belongs to the table, not the page. */
.molecule-items{margin-left:0}.molecule-columns-toggle{font-size:12px;padding:5px 9px;margin:0 0 8px 10px}.molecule-table{font-size:12px;width:100%;border-collapse:separate;border-spacing:0}.molecule-table th,.molecule-table td{white-space:normal;vertical-align:top;padding:8px;min-width:100px;max-width:180px;overflow-wrap:anywhere}.molecule-table th:first-child,.molecule-table td:first-child{min-width:150px;position:sticky;left:0;background:var(--sidebar);z-index:1}.molecule-table .selected td:first-child{background:var(--selected)}.molecule-table th:first-child{z-index:2}.molecule-table th button{font-size:12px;white-space:normal;text-align:left;min-height:36px}.molecule-table .item{font-size:13px;font-weight:500;padding:4px;min-height:36px;line-height:1.45}.molecule-table .item[aria-current=true]{font-weight:650}.molecule-scroll{max-width:100%;overscroll-behavior-inline:contain}.molecule-scroll:focus-visible{outline:3px solid var(--focus);outline-offset:-3px}#drawer .molecule-table th:first-child,#drawer .molecule-table td:first-child{background:var(--surface)}#drawer .molecule-table .selected td:first-child{background:var(--selected)}

.molecule-scroll{container-type:inline-size}
@container (max-width:300px){.molecule-table th:first-child,.molecule-table td:first-child{position:static}}

/* Symbolic sugar units: fixed white surface, never a computed molecular geometry. */
.polymer-diagram{margin:0;width:min(100%,600px);min-width:0}.polymer-diagram svg{display:block;width:100%;height:auto;background:#fff;border:1px solid #c8d4d7;border-radius:10px;color:#172e38;font-family:system-ui,sans-serif}.diagram-bond{stroke:#344d57;stroke-width:3}.unit-glc{fill:#e1f2f0;stroke:#326f69;stroke-width:2}.unit-fru{fill:#f9ecd5;stroke:#896328;stroke-width:2}.diagram-label{font-size:20px;fill:#172e38}.diagram-unit{font-size:24px;font-weight:650;fill:#172e38}.diagram-heading{font-size:21px;font-weight:650;fill:#172e38}.diagram-small{font-size:16px;fill:#344d57}.diagram-legend{font-size:12px;line-height:1.6;margin:10px 0;color:var(--text)}.polymer-diagram .caption{line-height:1.6}.polymer-diagram a{display:inline-block;margin-inline-end:5px}

/* Consumer-owned renderer surface; the module retains camera/picking/lifecycle. */
#viewSurface{gap:12px;justify-content:flex-start;min-height:0}
.viewer-tools{display:flex;flex-wrap:wrap;gap:6px;align-items:center;width:100%;padding-top:14px}
.viewer-tools:empty{display:none}.viewer-tools button{font-size:12px;padding:6px 9px;min-height:34px}
.viewer-tools [aria-pressed=true]{background:var(--selected);border-color:var(--accent);color:var(--accent)}
.viewer-control{display:inline-flex;align-items:center;flex-wrap:wrap;gap:5px;font-size:12px;color:var(--muted)}
.viewer-control select{max-width:210px;background:var(--surface);color:var(--text);border:1px solid var(--border);border-radius:5px;font:inherit;min-height:34px;padding:4px}
.viewer-control input{width:90px}.model-viewport{width:100%;min-height:230px;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:12px;flex:1}
.model-viewport.interactive{position:relative;height:clamp(280px,42vh,520px);min-height:280px;flex:1 0 280px;background:#e8edf0;border-radius:10px;overflow:hidden;color:#25313d}
.model-viewport.interactive .studio-view-toolbar{display:none!important}
.model-caption{max-width:850px;margin:0;font-size:11px;line-height:1.45}.model-status{margin:0 0 8px;font-size:11px;line-height:1.45}
#viewSurface[data-renderer-state=fallback] .model-status{color:var(--warning)}
@media(max-width:700px){.viewer-tools{gap:5px}.viewer-tools button{min-height:44px}.model-viewport.interactive{height:320px;flex-basis:320px}.viewer-control select{max-width:190px}.model-caption,.model-status{text-align:left}.model-viewport img{max-height:45vh}#workspace{height:auto;min-height:calc(100dvh - 170px)}#viewer{height:auto;overflow:visible}}

/* Visible compact language codes; native buttons expose the selected locale. */
#version{font-size:11px;color:var(--muted);margin-left:auto;text-decoration:underline;text-underline-offset:3px;white-space:nowrap}.release-history{max-width:850px;margin:36px auto;padding:20px;line-height:1.7}.release-history li{margin:16px 0}
#language{display:flex;flex:none;gap:0;margin-left:auto}#language button{min-width:36px;min-height:40px;padding:6px;font-size:12px;border-radius:0}#language button:first-child{border-radius:7px 0 0 7px}#language button:last-child{border-radius:0 7px 7px 0;border-left:0}#language [aria-pressed=true]{background:var(--selected);color:var(--accent);font-weight:750;text-decoration:underline;text-underline-offset:4px}#settings{margin-left:0}.appbar{column-gap:24px}
@media(max-width:760px){.appbar{display:grid;grid-template-columns:minmax(0,1fr) auto auto;height:auto;min-height:100px;padding:8px 12px;gap:4px 10px}.appbar .brand{grid-column:1;grid-row:1;font-size:17px}.appbar #language{grid-column:2;grid-row:1;margin:0}.appbar #settings{grid-column:3;grid-row:1;justify-self:end;width:36px;height:40px}.appbar nav{grid-column:1/3;grid-row:2;margin:0;height:40px;gap:18px}.appbar #menu{grid-column:3;grid-row:2;margin:0;padding:7px;font-size:12px;min-height:40px}#language button{min-height:40px;min-width:36px}}

/* Ion markers are illustrative colour keys, not measured ionic surfaces. */
.ion-key{display:inline-flex;align-items:center;gap:5px;margin-inline-end:12px;white-space:nowrap;color:var(--text)}.ion-key::before{content:"";width:12px;height:12px;border:1px solid var(--border);border-radius:50%;display:inline-block}.ionic-na::before{background:#8d71db}.ionic-cl::before{background:#3d9875}
/* Floor controls remain inside the existing device-local settings, not the viewing toolbar. */
#settingsDialog #floorSettings{margin-top:20px}#floorSettings label{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;margin:8px 0;min-height:44px}#floorSettings .hint{font-size:12px;line-height:1.5}#floorSettings .floor-slider{display:flex;align-items:center;gap:8px;flex:1 1 180px;min-width:0}#floorSettings input[type=range]{flex:1;width:100%;min-width:80px;min-height:44px;accent-color:var(--accent)}#floorSettings output{width:48px;text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}#floorSettings input[type=checkbox]{width:20px;height:20px;accent-color:var(--accent)}#floorSettings input[type=color]{width:56px;height:44px;background:var(--surface);border:1px solid var(--border);border-radius:7px;padding:4px}#floorMaterial summary{min-height:44px;cursor:pointer;padding-block:10px;color:var(--muted)}#floorReset{min-height:44px;margin-top:8px}#settingsDialog summary:focus-visible,#floorSettings select:focus-visible{outline:3px solid var(--focus);outline-offset:3px}

.protein-sequence{margin:0;width:min(100%,630px);padding:16px;border:1px solid var(--border);border-radius:10px}
.protein-sequence figcaption,.protein-sequence p{font-size:.9rem}
.protein-sequence h3{margin:12px 0 4px;font-size:1rem}
.protein-sequence section div{display:grid;grid-template-columns:3ch minmax(0,auto) 3ch;gap:.45rem;justify-content:start;align-items:baseline}
.protein-sequence section span{font-size:.75rem;font-variant-numeric:tabular-nums;text-align:right}
.protein-sequence code{font-size:clamp(.68rem,2.9vw,1rem);letter-spacing:.06em;overflow-wrap:anywhere}

.peptide-controls{display:flex;flex-wrap:wrap;align-items:center;gap:6px 12px;width:100%;margin:6px 0}
.peptide-controls[hidden]{display:none}
.peptide-controls input{width:auto}
.peptide-switch{display:inline-flex;gap:3px}
.peptide-switch button{font-size:12px;padding:6px 9px;min-height:34px}
.peptide-switch [aria-pressed=true]{background:var(--selected);border-color:var(--accent);color:var(--accent)}
@media(max-width:700px){.peptide-switch button,.peptide-controls .viewer-control{min-height:44px}}

#itemName{overflow-wrap:anywhere}
.viewer-tools .viewer-control input[type=checkbox]{width:18px;height:18px;margin:0}

.atom-count-note{border:0;border-radius:3px;background:transparent;color:var(--accent);text-decoration:underline dotted;text-underline-offset:3px;padding:0 6px;font-weight:700;min-width:24px;line-height:1.25}
.atom-count-hint{position:fixed;inset:auto;margin:0;width:max-content;max-width:min(330px,calc(100vw - 16px));max-height:calc(100dvh - 16px);overflow:auto;padding:10px 12px;background:var(--surface);color:var(--text);border:1px solid var(--border);border-radius:7px;box-shadow:0 6px 24px #0006;font-size:12px;line-height:1.5}
.atom-count-hint p{margin:0 0 8px}.atom-count-hint-close{font-size:12px;padding:3px 8px;float:right}
/* Workspace overlays and compact catalogue density. */
body:has(> #workspace) {
 display:grid;
 grid-template-rows:auto minmax(0,1fr) auto auto;
 height:100dvh;
}
#workspace {
 height:auto;
 min-height:0;
 overflow:hidden;
}
#side { padding:12px 12px 16px; }
#catalogue .nav-label { margin:0 0 6px; padding-inline:6px; }
#catalogue .group-toggle { padding:5px 6px; min-height:28px; line-height:1.2; }
#catalogue .molecule-columns-toggle { padding:2px 6px; margin:0 0 3px 5px; }
#catalogue .items .hint { margin:3px 6px; }
#catalogue .tools { margin-bottom:4px; }
#catalogue th, #catalogue td { padding:2px 5px; vertical-align:middle; }
#catalogue th button { min-height:23px; padding:1px 3px; line-height:1.15; }
#catalogue .molecule-table .item {
 min-height:22px;
 padding:2px 3px;
 line-height:1.25;
 overflow-wrap:anywhere;
}
#catalogue td button:focus-visible, #catalogue th button:focus-visible { outline-offset:-2px; }
@media (pointer:coarse) {
 #catalogue .group-toggle, #catalogue .molecule-columns-toggle,
 #catalogue th button, #catalogue td button, #catalogue .molecule-table .item { min-height:44px; }
}

#viewer {
 --viewer-edge:8px;
 --viewer-tools-space:54px;
 position:relative;
 display:block;
 min-height:0;
 height:100%;
 padding:0;
 overflow:hidden;
 isolation:isolate;
 container-type:inline-size;
}
#viewSurface {
 position:absolute;
 inset:0;
 display:block;
 min-height:0;
 padding:0;
}
#viewer .model-viewport {
 position:absolute;
 inset:0;
 width:100%;
 height:100%;
 min-height:0;
 border-radius:0;
}
#viewer .model-viewport:not(.interactive) {
 display:block;
 overflow:auto;
 padding:12px calc(min(320px,46%) + 2 * var(--viewer-edge)) var(--viewer-tools-space) 12px;
 overscroll-behavior:contain;
}
#viewer .model-viewport:not(.interactive) > * { margin-inline:auto; }
#viewer .model-viewport:not(.interactive) > img { display:block; }
#itemInfo {
 position:absolute;
 z-index:2;
 inset-block-start:var(--viewer-edge);
 inset-inline-end:var(--viewer-edge);
 width:min(320px,46%);
 max-height:min(47%,calc(100% - var(--viewer-tools-space) - var(--viewer-edge)));
 overflow:auto;
 overscroll-behavior:contain;
 overflow-wrap:anywhere;
 padding:8px 10px;
 border:1px solid var(--border);
 border-radius:8px;
 background:color-mix(in srgb,var(--surface) 95%,transparent);
}
#itemInfo .eyebrow { margin:0 0 2px; font-size:10px; }
#itemName { margin:0; font-size:clamp(17px,2vw,23px); line-height:1.12; letter-spacing:-.025em; }
#itemInfo .formula { font-size:14px; margin:3px 0 0; }
#itemInfo #moleculeInfo { font-size:12px; line-height:1.35; margin-top:6px; }
#infoTitle { font-size:12px; line-height:1.25; margin:0 0 4px; }
#itemInfo .badges { gap:3px; }
#itemInfo .badge { padding:1px 5px; font-size:10px; }
#itemInfo .molecule-note { margin:5px 0 2px; }
#itemInfo #fructoseFormHint { margin:3px 0 5px; line-height:1.35; }
#itemInfo .model-caption, #itemInfo .model-status { text-align:start; margin:4px 0 0; line-height:1.3; }
#itemInfo .model-help { margin-top:4px; font-size:11px; line-height:1.3; }
#itemInfo .model-help summary { cursor:pointer; text-decoration:underline; text-underline-offset:2px; }
#itemInfo .model-help p { margin:4px 0 0; }
#itemInfo .model-caption:empty, #itemInfo .model-status:empty { display:none; }
#viewer:has([data-renderer-state=fallback]) .model-status { color:var(--warning); }

#viewer .viewer-bar {
 position:absolute;
 z-index:3;
 inset-block-end:var(--viewer-edge);
 inset-inline:0;
 margin-inline:auto;
 display:flex;
 align-items:stretch;
 width:max-content;
 max-width:calc(100% - 2 * var(--viewer-edge));
 box-sizing:border-box;
 border:1px solid var(--border);
 border-radius:8px;
 background:color-mix(in srgb,var(--surface) 96%,transparent);
}
#viewer .viewer-tools {
 display:flex;
 flex-wrap:nowrap;
 align-items:center;
 gap:4px;
 width:auto;
 min-width:0;
 padding:3px;
 overflow-x:auto;
 overflow-y:hidden;
 overscroll-behavior-inline:contain;
 scrollbar-width:thin;
}
#viewer .viewer-tools > *, #viewer .peptide-controls > * { flex:none; }
#viewer .viewer-bar button, #viewer .viewer-bar select { min-height:30px; line-height:1.15; }
#viewer .viewer-bar button { min-width:30px; padding:3px 6px; }
#viewer .viewer-bar :focus-visible, #itemInfo:focus-visible { outline-offset:-2px; }
#viewer .viewer-bar .view-icon { width:17px; height:17px; display:block; margin:auto; }
#viewer .viewer-bar .viewer-control { flex-wrap:nowrap; white-space:nowrap; min-height:30px; }
#viewer .viewer-bar .viewer-control input[type=range] { width:66px; }
#viewer .viewer-bar .viewer-control input[type=color] { width:29px; height:27px; }
#viewer .viewer-bar .peptide-controls { width:auto; margin:0; gap:6px; flex-wrap:nowrap; }
#viewer .viewer-bar .peptide-controls[hidden], #viewer .viewer-scroll[hidden] { display:none; }
#viewer .viewer-scroll { flex:none; border-radius:6px; margin:2px; }
@media (pointer:coarse) {
 #viewer { --viewer-tools-space:62px; }
 #viewer .viewer-bar button, #viewer .viewer-bar select, #viewer .viewer-bar .viewer-control {
  min-height:44px;
 }
 #viewer .viewer-bar button { min-width:44px; }
 #viewer .viewer-bar .viewer-control { padding-inline:4px; }
}
@container (max-width:640px) {
 #itemInfo { width:min(280px,55%); max-height:min(47%,calc(100% - var(--viewer-tools-space))); }
 #viewSurface .model-viewport:not(.interactive) {
  padding-inline:10px;
  padding-block-start:calc(var(--viewer-edge) * 2 + var(--info-height, 0px));
 }
}
@media (max-width:420px) {
 #itemInfo { width:min(250px,calc(100% - 54px)); max-height:46%; }
}
@media (max-height:500px) and (orientation:landscape) {
 #itemInfo {
  width:min(285px,45%);
  max-height:calc(100% - var(--viewer-tools-space) - var(--viewer-edge));
  padding:6px 8px;
 }
 #itemInfo #moleculeInfo { margin-top:4px; }
 #itemInfo .molecule-note { font-size:11px; line-height:1.3; }
}

/* One table, one filter, and one shared column chooser. */
.molecule-options { display:flex; flex-wrap:wrap; align-items:end; gap:5px; margin:0 0 4px; }
.molecule-filter {
 display:flex;
 align-items:center;
 gap:5px;
 flex:0 1 auto;
 min-width:0;
 font-size:12px;
}
.molecule-filter select { min-width:0; max-width:100%; flex:none; padding:3px 5px; }
.catalogue-explanation{font-size:11px;line-height:1.45;color:var(--muted);margin:5px 0 8px}.catalogue-explanation summary{cursor:pointer}.catalogue-explanation p{margin:6px 0;overflow-wrap:anywhere}.matched-synonym{display:block;font-size:11px;line-height:1.4;color:var(--muted);overflow-wrap:anywhere}
.catalogue-search{display:flex;align-items:center;gap:6px;margin:5px 0 8px;padding:3px 7px;border:1px solid var(--border);border-radius:6px;background:var(--surface);font-size:13px}
.catalogue-search span{font-size:21px;line-height:1;color:var(--muted)}
.catalogue-search input{border:0;background:transparent;color:var(--text);width:100%;min-width:0;padding:3px;font-size:12px}
.atom-layout-tools{display:flex;flex-wrap:wrap;gap:4px;margin-bottom:8px}.atom-layout-tools button{font-size:12px;padding:4px 7px}.atom-layout-tools [aria-pressed=true]{background:var(--selected);border-color:var(--accent)}
.periodic-scroll{max-width:100%;overflow:auto;overscroll-behavior:contain;padding:3px}
.periodic-grid{display:grid;grid-template-columns:16px repeat(18,minmax(26px,1fr));grid-template-rows:18px repeat(7,44px);gap:2px;min-width:540px}
.periodic-empty{border:1px solid var(--divider);opacity:.28;border-radius:4px}
.periodic-group,.periodic-period{font-size:9px;color:var(--muted);text-align:center;align-self:center}
.periodic-cell{position:relative;min-width:0;padding:2px;border-radius:4px;display:flex;flex-direction:column;align-items:center;justify-content:center;background:var(--surface);line-height:1.1}
.periodic-cell small{font-size:9px;color:var(--muted)}.periodic-cell strong{font-size:13px}.periodic-cell.selected{background:var(--selected);border-color:var(--accent);color:var(--accent)}
@media(pointer:coarse){.catalogue-search input{min-height:38px;font-size:16px}.atom-layout-tools button{min-height:44px}.periodic-grid{grid-template-columns:16px repeat(18,44px);min-width:844px}.periodic-cell{min-height:44px}}
#catalogue .molecule-options .molecule-columns-toggle { margin:0; min-height:27px; }
#moleculeColumnsDialog { width:min(340px,calc(100vw - 24px)); max-height:calc(100dvh - 24px); }
#moleculeColumnsDialog header { display:flex; align-items:center; justify-content:space-between; gap:12px; }
#moleculeColumnsDialog h2 { font-size:18px; margin:0; }
#mcolumnChoices { margin:10px 0 0; }
#mcolumnChoices label { min-height:34px; }
@media (pointer:coarse) {
 .molecule-filter select, #catalogue .molecule-options .molecule-columns-toggle,
 #closeMoleculeColumns, #mcolumnChoices label { min-height:44px; }
}

/* Fixed catalogue chrome; only the table/grid owns catalogue scrolling. */
#side { overflow:hidden; display:flex; flex-direction:column; }
#catalogue { display:flex; flex-direction:column; min-height:0; height:100%; }
#catalogue > :not(.items):not(.table-scroll):not(.periodic-scroll) { flex-shrink:0; }
#catalogue .molecule-options { flex-wrap:nowrap; align-items:center; gap:4px; margin:0 0 6px; }
#catalogue .molecule-filter { flex:0 1 auto; max-width:48%; }
#catalogue .molecule-filter select { flex:0 1 auto; width:100%; text-overflow:ellipsis; font-size:12px; height:30px; }
#catalogue .catalogue-search { flex:1 1 60px; min-width:0; margin:0; gap:2px; padding:0 4px; height:30px; }
#catalogue .catalogue-search input { width:100%; min-width:0; height:100%; }
#catalogue .molecule-options .molecule-columns-toggle { flex:none; width:28px; height:30px; padding:0; font-size:19px; }
#catalogue .items { flex:1 1 auto; display:flex; flex-direction:column; min-height:0; margin:0; overflow:hidden; }
#catalogue .table-scroll, #catalogue .periodic-scroll { flex:1 1 auto; min-height:0; overflow:auto; overscroll-behavior:contain; }
#catalogue .table-scroll table { border-collapse:separate; border-spacing:0; }
#catalogue th { position:sticky; top:0; z-index:3; background:var(--sidebar); }
#catalogue .molecule-table th:first-child { position:sticky; top:0; z-index:4; }
#drawer #catalogue th { background:var(--surface); }
#catalogue > .hint { margin:5px 3px 0; font-size:11px; line-height:1.4; }
#drawer[open] { display:flex; flex-direction:column; overflow:hidden; }
#drawer > header { flex:none; margin-bottom:12px; }
#mobileCatalogue { flex:1; min-height:0; }
.periodic-grid { grid-template-rows:18px repeat(7,44px) 8px repeat(2,44px); }
.periodic-unavailable { background:#7772; border:1px solid #8888; color:var(--periodic-disabled); cursor:default; }
.periodic-unavailable small { color:inherit; }
.periodic-series-range { display:grid; place-items:center; font-size:9px; color:var(--muted); }
.periodic-series-label { align-self:center; text-align:right; padding-right:5px; font-size:10px; color:var(--muted); }
#about { display:grid; place-items:center; width:30px; height:30px; padding:0; border:0; background:transparent; font-size:23px; line-height:1; }
#aboutDialog { width:min(540px,calc(100vw - 24px)); max-height:calc(100dvh - 24px); overflow:auto; }
@media (pointer:coarse) {
 #catalogue .molecule-filter select, #catalogue .catalogue-search,
 #catalogue .molecule-options .molecule-columns-toggle { height:44px; min-height:44px; }
 #catalogue .molecule-options .molecule-columns-toggle { width:32px; }
 #catalogue .catalogue-search input { min-height:0; font-size:16px; }
 #about { width:44px; height:44px; }
}
@media (max-width:760px) { #side { display:none; } }

/* Narrow tables do not pin the name column: its header must track its cells
   horizontally while remaining sticky vertically. */
@container (max-width:300px) {
 #catalogue .molecule-table th:first-child { left:auto; }
}

/* Disabled elements are neutral, intentionally quieter than prepared models. */
:root { --periodic-disabled:#929292; }
:root[data-theme=studio] { --periodic-disabled:#737373; }
:root[data-theme=fieldnotes] { --periodic-disabled:#929292; }
/* In periodic mode the actual live description follows the complete grid in
   its scroll flow, not the renderer. Keep the layout controls fixed above it. */
.periodic-scroll > .hint { margin:8px 3px; font-size:11px; line-height:1.4; }
.periodic-scroll > #itemInfo {
 position:static;
 width:auto;
 max-height:none;
 overflow:visible;
 margin-top:10px;
 background:var(--surface);
}

/* Dialog header chrome must not turn the reparented element heading into a row. */
.periodic-scroll > #itemInfo > header { display:block; margin:0; }

/* Molecule facts dock naturally at the catalogue bottom, including its mobile
   drawer. Long disclosures scroll within the dock, leaving the table usable. */
#catalogue > #itemInfo {
 position:static;
 flex:0 0 auto;
 min-height:0;
 width:auto;
 max-height:45%;
 margin:8px 0 0;
 overflow:auto;
 background:var(--surface);
}
#catalogue > #itemInfo > header { display:block; margin:0; }
#catalogue #moleculeList > [role=status] {
 flex:none;
 margin:6px 3px;
 font-size:12px;
 line-height:1.4;
}
/* Fallback diagrams no longer reserve an empty right-hand description column. */
#viewer:not(:has(> #itemInfo)) .model-viewport:not(.interactive) {
 padding:12px 12px var(--viewer-tools-space);
}

/* Source-derived A diagrams use a theme palette, not a raster white tile. */
#viewSurface img.molecule-svg { background:var(--surface); padding:8px; width:100%; max-width:1100px; height:auto; aspect-ratio:1024/560; object-fit:contain; }
